-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (65 loc) · 1.87 KB
/
update-data.yml
File metadata and controls
70 lines (65 loc) · 1.87 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
name: Update Data
on:
workflow_dispatch: # Manual trigger
push:
branches: [ main ]
schedule:
- cron: '0 12 * * *' # 6 AM Chicago (CST), 7 AM during CDT
permissions:
contents: write
pages: write
id-token: write
jobs:
create:
if: ${{ github.event_name == 'workflow_dispatch'
|| github.event_name == 'schedule'
|| contains(github.event.head_commit.message, 'data update') }}
name: create dataset
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
pushed: ${{ steps.commit.outputs.pushed }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: clean dir
run: |
rm -rf data
mkdir data
- name: Run script
run: |
python scripts/create_dataset.py
ls data
- name: check if successful, then commit
id: commit
run: |
if [ -f done ]; then
echo "generated dataset successfully"
git config user.name github-actions
git config user.email github-actions@github.com
git add -A data/
if git diff --cached --quiet; then
echo "no data changes to commit"
echo "pushed=false" >> $GITHUB_OUTPUT
else
git commit -m "Update data"
git push
echo "pushed=true" >> $GITHUB_OUTPUT
fi
else
echo "failed to generate dataset"
echo "pushed=false" >> $GITHUB_OUTPUT
fi
deploy:
needs: create
if: needs.create.outputs.pushed == 'true'
uses: ./.github/workflows/deploy.yml