Sync JSON Data #5
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: Sync JSON Data | |
on: | |
schedule: | |
# This schedule will run every day at midnight UTC (modify as needed) | |
- cron: '0 * * * *' | |
workflow_dispatch: # Allows manual trigger | |
permissions: | |
contents: write | |
jobs: | |
sync-json: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout π | |
uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.KEY_UPDATE_LAWS_DATA }} # Ensure that this SSH key has proper permissions | |
- name: Setup node env π | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: yarn | |
- name: Install dependencies π¨π»βπ» | |
run: yarn --ignore-engines | |
- name: Fetch data ππ»ββοΈ | |
run: | | |
curl -s "https://script.google.com/macros/s/${{ secrets.KEY_APP_SCRIPT }}/exec?action=getData" -o data/laws.json | |
- name: Commit and Push Changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add data/laws.json | |
git commit -m "Sync JSON data from Google Apps Script" | |
git push origin HEAD:refs/heads/main |