Fetch Daily Data #848
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: 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 |