forked from w3f/Grants-Program
-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (108 loc) · 4.46 KB
/
Copy pathgoogle_sheet_update.yml
File metadata and controls
118 lines (108 loc) · 4.46 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Google Sheet Update
on:
pull_request_target:
types: [closed]
jobs:
update_sheet:
runs-on: ubuntu-latest
steps:
- name: 'get all added files in the PR'
if: ${{ github.event.pull_request.merged == true && !env.ACT }}
id: 'files'
uses: mmagician/get-changed-files@v2
# - name: 'local test: get all added files in the PR'
# if: ${{ env.ACT }}
# id: 'files'
# run: echo "::set-output name=added::$(echo applications/workflow_testing1.md5 applications/workflow_testing.md)"
- name: Checkout
uses: actions/checkout@master
if: ${{ github.event.pull_request.merged == true && !env.ACT }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Local Testing Checkout
uses: actions/checkout@master
if: ${{ env.ACT }}
- name: 'filter only .md added files'
if: github.event.pull_request.merged == true
id: 'filter'
run: |
for filename in ${{ steps.files.outputs.added }}
do
if [[ $filename =~ \.md$ ]]
then
echo "::set-output name=added::$filename"
break
fi
done
# - name: 'local testing parse files'
# if: ${{ env.ACT }}
# id: grant_parser
# uses: mmagician/read-file-action@v1
# with:
# path: "${{ steps.filter.outputs.added }}"
- name: 'parse files'
if: ${{ github.event.pull_request.merged == true && !env.ACT }}
id: grant_parser
uses: mmagician/read-file-action@v1
with:
path: "${{ github.workspace }}/${{ steps.filter.outputs.added }}"
- name: Get current date
if: github.event.pull_request.merged == true
id: date
run: echo "::set-output name=date::$(date +'%d/%m/%Y')"
- name: Get last row
if: github.event.pull_request.merged == true
id: get_last_row
uses: w3f/gsheet.action@v1.1.4
with:
spreadsheetId: ${{ secrets.SPREADSHEET_ID }}
startRow: 260
worksheetTitle: "Legal"
env:
GSHEET_CLIENT_EMAIL: ${{ secrets.GSHEET_CLIENT_EMAIL }}
GSHEET_PRIVATE_KEY: ${{ secrets.GSHEET_PRIVATE_KEY }}
- name: 'write the data to a gsheet'
if: github.event.pull_request.merged == true
id: 'update_worksheet'
uses: jroehl/gsheet.action@v1.0.0 # you can specify '@release' to always have the latest changes
with:
spreadsheetId: ${{ secrets.SPREADSHEET_ID }}
commands: | # list of commands, specified as a valid JSON string
[
{
"command": "updateData",
"args":
{
"data": [[
"${{ steps.grant_parser.outputs.team_name }}",
"${{ steps.grant_parser.outputs.team_name }}",
"Open Grants",
"${{ steps.grant_parser.outputs.project_name }}",
"${{ steps.grant_parser.outputs.address }}",
"${{ steps.grant_parser.outputs.contact_name }}",
"${{ steps.grant_parser.outputs.contact_name }}",
"${{ steps.grant_parser.outputs.contact_title }}",
"${{ steps.grant_parser.outputs.contact_email }}",
"${{ steps.grant_parser.outputs.country }}",
"",
"https://github.com/w3f/Open-Grants-Program/pull/${{ github.event.pull_request.number }}",
"https://github.com/w3f/Open-Grants-Program/pull/${{ github.event.pull_request.number }}",
"USD", "0", "0", "0",
"${{ steps.grant_parser.outputs.total_cost_btc }}",
"${{ steps.grant_parser.outputs.total_cost_dai }}",
"",
"",
"Signed",
"https://github.com/w3f/Open-Grants-Program/pull/${{ github.event.pull_request.number }}",
"${{ steps.date.outputs.date }}"
]],
"worksheetTitle": "Legal",
"minCol": 1,
"minRow": "${{ steps.get_last_row.outputs.lastRow }}",
"valueInputOption": "USER_ENTERED"
}
}
]
env:
GSHEET_CLIENT_EMAIL: ${{ secrets.GSHEET_CLIENT_EMAIL }}
GSHEET_PRIVATE_KEY: ${{ secrets.GSHEET_PRIVATE_KEY }}