forked from w3f/Grant-Milestone-Delivery
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (86 loc) · 3.98 KB
/
google_sheet_update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Google Sheet Update
on:
pull_request_target:
types: [opened, synchronize]
jobs:
get-delivery-once:
runs-on: ubuntu-latest
outputs:
has-succeeded: ${{ steps.check-no-success.outputs.has-succeeded }}
filenames: ${{ steps.delivery.outputs.filenames }}
milestone-number: ${{ steps.delivery.outputs.milestone-number }}
application-filename: ${{ steps.delivery.outputs.application-filename }}
steps:
- uses: actions/checkout@v2
- name: Parse delivery file
id: delivery
uses: ./.github/workflows/composite/get_delivery
- name: Check that the workflow didn't yet run successfully in this PR
uses: actions/github-script@v5
id: check-no-success
if: steps.delivery.outputs.filenames
with:
script: |
// https://octokit.github.io/rest.js/v18
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'google_sheet_update.yml',
status: 'success',
per_page: 100
});
const pr_commits = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ github.event.number }},
per_page: 100
});
const runs_shas = runs.data.workflow_runs.map(run => {return run.head_sha});
const pr_shas = pr_commits.data.map(c => {return c.sha});
core.setOutput("has-succeeded", pr_shas.filter(s => runs_shas.includes(s)).length != 0);
update-sheet: # TODO run for each delivery if PR contains more than one (see also get_delivery.yml)
needs: get-delivery-once
if: needs.get-delivery-once.outputs.filenames && needs.get-delivery-once.outputs.has-succeeded == 'false'
runs-on: ubuntu-latest
steps:
- name: Get application file
run: wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/applications/${{ needs.get-delivery-once.outputs.application-filename }}"
- name: Parse application file
id: parse-grant
uses: w3f/parse-grant-application-action@v1
with:
path: "${{ needs.get-delivery-once.outputs.application-filename }}"
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%d/%m/%Y')"
- name: Write data to sheet
uses: jroehl/[email protected]
with:
spreadsheetId: ${{ secrets.SPREADSHEET_ID }}
commands: |
[
{
"command": "appendData",
"args":
{
"data": [[
"=IFERROR(HYPERLINK(\"#gid=0&range=\" & MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))), Legal!$D:$D, 0) & \":\" & MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))), Legal!$D:$D, 0), INDEX(Legal!$A$2:$A,MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))),Legal!$D$2:$D,0))), \"\")",
"${{ steps.parse-grant.outputs.project_name }}",
"${{ needs.get-delivery-once.outputs.milestone_number }}",
"",
"Not Yet",
"=IFERROR(SWITCH(INDIRECT(ADDRESS(ROW(),COLUMN()-1)), \"Not Yet\", 3, \"In Progress\", 2, \"Asked for Changes\", 1, \"Final Check\", 2, \"Done\", 0, \"Terminated\", 0))",
"=INDEX(Legal!$W$2:$W,MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))),Legal!$D$2:$D,0))",
"${{ github.event.pull_request.html_url }}",
"",
"${{ steps.date.outputs.date }}"
]],
"worksheetTitle": "Evaluation",
"minCol": 1,
"valueInputOption": "USER_ENTERED"
}
}
]
env:
GSHEET_CLIENT_EMAIL: ${{ secrets.GSHEET_CLIENT_EMAIL }}
GSHEET_PRIVATE_KEY: ${{ secrets.GSHEET_PRIVATE_KEY }}