Run Fetch Task and Commit Data #2860
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
# github action to run `fetch` task using npm and commit changes | |
name: Run Fetch Task and Commit Data | |
on: | |
schedule: | |
- cron: "0 * * * *" # Runs every hour at the beginning of the hour | |
workflow_dispatch: | |
jobs: | |
fetch_task: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install | |
- name: Run fetch task | |
run: npm run fetch | |
- name: Commit and push if there are changes | |
run: | | |
git config --global user.email "action@github.com" | |
git config --global user.name "GitHub Action" | |
git add src/data/* | |
git commit -m "Automated data update" -a || echo "No changes to commit" | |
git push | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |