Update target data #18
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 target data | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '00 17 * * 3' | |
jobs: | |
update-target-data: | |
if: ${{ github.repository_owner == 'CDCgov' }} | |
runs-on: ubuntu-22.04 | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Get Token | |
id: get_workflow_token | |
uses: peter-murray/workflow-application-token-action@v4 | |
with: | |
application_id: ${{ vars.GH_APP_ID }} | |
application_private_key: ${{ secrets.GH_APP_KEY }} | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
install-r: false | |
use-public-rspm: true | |
- name: Install dependencies | |
run: | | |
install.packages(c("argparser", "fs", "readr", "dplyr", "remotes", "RcppTOML")) | |
remotes::install_github('cdcgov/forecasttools') | |
shell: Rscript {0} | |
- name: get updated target data | |
run: | | |
Rscript src/get_covid_hosp_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: Check for Changes | |
id: check_diff | |
run: | | |
git diff --exit-code target-data/covid-hospital-admissions.csv || echo "changed=true" >> $GITHUB_ENV | |
- name: Commit changes | |
if: env.changed == 'true' | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: "Update target data" | |
default_author: github_actions | |
push: true | |
new_branch: update-target-data | |
- name: Create pull request | |
if: env.changed == 'true' | |
run: | | |
gh pr create --base main --head update-target-data --title "Update target data" --body "This PR updates the covid-19 hospital admissions data based on the latest NHSN wednesday data release." | |
env: | |
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }} |