Check for metadata changes #51
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: | |
| 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 | |
| # Commit or not based on env variable passed from R | |
| - name: Print $UPDATED_DATA | |
| run: echo "endpoints.csv changed:" $UPDATED_DATA | |
| - name: If the cached CSV has not changed, finish | |
| if: env.UPDATED_DATA == 'false' | |
| run: echo "no changes, nothing committed" | |
| - name: Set up commit | |
| if: env.UPDATED_DATA == 'true' | |
| 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 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 ${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 ${timestamp}" || exit 0 | |
| git push |