Check for metadata changes #84
This file contains hidden or 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
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # Run once per day | |
| - cron: "0 13 * * *" | |
| name: Check for metadata changes | |
| jobs: | |
| check_data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Install R and dependencies | |
| - uses: r-lib/actions/setup-r@v2 | |
| - uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| packages: | | |
| censusapi | |
| # Run R script to grab metadata and compare against saved .csv | |
| - name: Run update-metadata.R | |
| run: | | |
| Rscript scripts/update-metadata.R | |
| echo "endpoints.csv changed:" $UPDATED_DATA | |
| # Commit or not based on env variable passed from R | |
| #- name: If the cached CSV has not changed, finish | |
| # run: echo "no changes, nothing committed" | |
| - name: Set up commit | |
| run: | | |
| # Configure git user | |
| git config user.name "hrecht[bot]" | |
| git config user.email "9753760+hrecht[bot]@users.noreply.github.com" | |
| # Commit files | |
| git add . | |
| - name: Push no data changes update | |
| if: env.UPDATED_DATA == 'false' && env.MAJOR_CHANGES == 'false' | |
| run: | | |
| timestamp=$(TZ=:America/New_York date '+%Y-%m-%d %H:%M') | |
| git commit -m "No data changes $TEST ${timestamp}" || exit 0 | |
| git push | |
| - name: Push minor changes update | |
| if: env.UPDATED_DATA == 'true' && env.MAJOR_CHANGES == 'false' | |
| run: | | |
| timestamp=$(TZ=:America/New_York date '+%Y-%m-%d %H:%M') | |
| git commit -m "Minor data change $TEST ${timestamp}" || exit 0 | |
| git push | |
| - name: Push major changes update | |
| if: env.UPDATED_DATA == 'true' && env.MAJOR_CHANGES == 'true' | |
| run: | | |
| timestamp=$(TZ=:America/New_York date '+%Y-%m-%d %H:%M') | |
| git commit -m "Major data change $TEST ${timestamp}" || exit 0 | |
| git push | |
| # Pause a little before deploying to github pages | |
| # Otherwise it's happening too quickly to work | |
| - name: Pause | |
| if: env.UPDATED_DATA == 'true' && env.MAJOR_CHANGES == 'true' | |
| run: | | |
| sleep 60 | |
| echo "Actions paused" | |
| build_site: | |
| needs: check_data | |
| uses: ./.github/workflows/deploy-site.yml | |
| secrets: inherit | |