-
Notifications
You must be signed in to change notification settings - Fork 58
51 lines (48 loc) · 1.47 KB
/
fetch-data.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
name: Fetch Daily Data
on:
workflow_dispatch:
schedule:
# "Everyday at 12:00 UTC (5:00 PT)" https://crontab.guru/#0_12_*_*_*
- cron: "0 12 * * *"
jobs:
fetch:
runs-on: ubuntu-latest
continue-on-error: true
outputs:
has_changes: ${{ steps.status.outputs.has_changes }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- run: npm run fetch:data -w data
continue-on-error: true
env:
AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for changes
id: status
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::set-output name=has_changes::1"
fi
- name: Commit changes
if: steps.status.outputs.has_changes == '1'
run: |
git add .
git commit -m "chore: update data"
git push origin ${{ github.ref_name }}
publish:
needs: fetch
if: needs.fetch.outputs.has_changes == '1'
uses: ./.github/workflows/publish.yml