Update Laws Data #3736
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 Laws Data | |
on: | |
schedule: | |
- cron: '0 * * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
concurrency: | |
group: github | |
cancel-in-progress: true | |
env: | |
TZ: 'Asia/Bangkok' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout π | |
uses: actions/checkout@v4 | |
- 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: | | |
touch .env | |
echo MONDAY_API_TOKEN=${{ secrets.MONDAY_API_TOKEN }} >> .env | |
echo MONDAY_BOARD_ID=${{ secrets.MONDAY_BOARD_ID }} >> .env | |
yarn config set ignore-engines true | |
yarn fetch-data | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: | | |
data/*.json | |
commit: | |
if: | | |
github.event.schedule || | |
github.event_name == 'workflow_dispatch' | |
name: Commit | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.KEY_UPDATE_LAWS_DATA }} | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: data | |
- name: Commit data | |
shell: bash | |
run: | | |
set -euxo pipefail | |
mv data/*/* data | |
if [ -n "$(git status -s data/{promises.json,laws.json})" ]; then | |
git config user.name github-actions | |
git config user.email [email protected] | |
echo 'Committing data...' | |
git add data | |
git diff --staged | |
git commit -m "π¦ update laws data $(date --iso-8601=seconds)" | |
git push | |
fi |