Update target data #45
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
| name: "Update target data" | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "00 16 * * 3" | |
| jobs: | |
| update-target-data: | |
| if: ${{ github.repository_owner == 'CDCgov' }} | |
| runs-on: "ubuntu-latest" | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: "Generate token" | |
| id: get_token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ vars.GH_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_KEY }} | |
| - name: "Check out code" | |
| uses: actions/checkout@v4 | |
| - name: "Set up R" | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| install-r: true | |
| use-public-rspm: true | |
| extra-repositories: "https://hubverse-org.r-universe.dev" | |
| - name: "Set up R dependencies" | |
| uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| pak-version: "devel" | |
| packages: | | |
| any::argparser | |
| any::tidyr | |
| any::RcppTOML | |
| any::hubData | |
| any::hubUtils | |
| github::cdcgov/forecasttools | |
| - name: "Update target timeseries data" | |
| run: | | |
| Rscript src/get_target_data.R --target-data TRUE --base-hub-path '.' | |
| env: | |
| NHSN_API_KEY_ID: ${{ secrets.NHSN_API_KEY_ID }} | |
| NHSN_API_KEY_SECRET: ${{ secrets.NHSN_API_KEY_SECRET }} | |
| - name: "Update oracle output from timeseries data" | |
| run: | | |
| Rscript src/generate_oracle_output.R --base-hub-path '.' | |
| - name: "Set Date" | |
| run: echo "DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV | |
| - name: "Check for Changes" | |
| id: check_diff | |
| run: | | |
| git diff --exit-code target-data/* || echo "changed=true" >> $GITHUB_ENV | |
| - name: "Commit Changes" | |
| if: env.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git checkout -b update-covid19-target-data-${{ env.DATE }} | |
| git add . | |
| git commit -m "Update covid-19 target data" | |
| git push origin update-covid19-target-data-${{ env.DATE }} | |
| - name: "Create pull request" | |
| if: env.changed == 'true' | |
| run: | | |
| gh pr create --base main --head update-covid19-target-data-${{ env.DATE }} --title "Update covid-19 target data" --body "This PR updates COVID-19 hospital admissions target data based on the latest released data." | |
| env: | |
| GH_TOKEN: ${{ steps.get_token.outputs.token }} |