update contracts #27390
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |