-
Notifications
You must be signed in to change notification settings - Fork 14
56 lines (56 loc) · 1.79 KB
/
update-contracts.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
name: update contracts
on:
push:
pull_request_target:
workflow_dispatch:
schedule:
- cron: "0 * * * *"
jobs:
update:
runs-on: ubuntu-latest
defaults:
run:
working-directory: misc/ContractAggregator
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "^1.16"
- name: Build
run: |
make
- name: Create config file
run: |
cat >config.toml <<EOF
[player]
id = "$API_USER_ID"
[database]
path = "data/contracts.db"
[export]
csv_path = "data/contracts.csv"
EOF
env:
API_USER_ID: ${{ secrets.UPDATE_CONTRACTS_API_USER_ID }}
- name: Update contracts
run: |
./ContractAggregator --bootstrap-csv
- name: Commit, push changes, and possibly trigger new build
run: |
git config user.name 'github-actions'
git config user.email 'actions@github.com'
git add data
git diff --cached --quiet || {
git commit -m 'misc/ContractAggregator: update contracts (from GitHub Actions)'
git push
# Use a separate personal access token since the token included doesn't seem to trigger
# anything, although the response (HTTP 204) looks all right.
curl -fsS -D- \
-X POST \
-H 'Authorization: Bearer ${{ secrets.WORKFLOW_DISPATCH_TOKEN }}' \
-H 'Accept: application/vnd.github.v3+json' \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches \
-d '{"ref": "'${GITHUB_REF##*/}'"}'
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}