This repository has been archived by the owner on Jul 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (48 loc) · 1.79 KB
/
update-data.yaml
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
# Fetch new report(s), update the data folder and push changes to the branch
# that triggered the workflow ("master" in case of scheduled executions).
# If no new reports are found, this workflow terminates with success.
#
# FIXME:
# - remove those ugly "if" when GitHub introduces some form of early exit
# (see https://github.com/actions/runner/issues/662)
#
name: Update data
on:
schedule:
# syntax: <minute> <hour> <day-of-the-year> <month> <day-of-the-week>
- cron: '0 11,14,17 * * *'
# Run three times a day: 12, 15, 18 (Italian time)
workflow_dispatch:
# enable manual triggering from GitHub
jobs:
update-data:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies # Caching doesn't seem to help
run: pip install -r src/requirements.txt
- name: Update the data if new reports were published
id: update-data
# Can't invoke the script inside echo string or the step will always succeed
# even if the script fails
run: >
UPDATED_FILES=$(python src/update_data.py)
&& echo "::set-output name=updated-files::$UPDATED_FILES"
- name: Commit changes
if: steps.update-data.outputs.updated-files != ''
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add data/
git commit -m "Auto-update data"
- name: Push changes
if: steps.update-data.outputs.updated-files != ''
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}