Update Quotes #37
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: Update Quotes | |
on: | |
schedule: | |
- cron: "0 3 * * 5" # Runs every Friday at midnight UTC | |
workflow_dispatch: # Allows manually trigger | |
permissions: | |
contents: write | |
jobs: | |
update-quotes: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install axios puppeteer | |
- name: Run script | |
run: node backend/dataload.js | |
- name: Check for change | |
run: | | |
if git diff --exit-code backend/quotes.json; then | |
echo "No changes to quotes.json, skipping commit, check logs." | |
echo "changes=false" >> $GITHUB_ENV | |
else | |
echo "Changes Detected, committing" | |
echo "changes=true" >> $GITHUB_ENV | |
fi | |
id: check_changes | |
- name: Commit and push changes | |
if: env.changes == 'true' | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add backend/quotes.json | |
git commit -m 'Update quotes' | |
git push |