|
| 1 | +name: Pull ensembles |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + name: |
| 6 | + description: 'Pull Ensembles' |
| 7 | + required: false |
| 8 | + publish: |
| 9 | + description: 'Pull ensemble forecasts' |
| 10 | + type: boolean |
| 11 | + required: false |
| 12 | + default: true |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + pull_ensembles: |
| 20 | + if: github.repository_owner == 'cdcepi' |
| 21 | + runs-on: macOS-latest |
| 22 | + steps: |
| 23 | + - name: Checkout repo |
| 24 | + uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + - name: Setup R |
| 28 | + uses: r-lib/actions/setup-r@v2 |
| 29 | + with: |
| 30 | + use-public-rspm: true |
| 31 | + - name: Install dependencies |
| 32 | + run: | |
| 33 | + install.packages("pak") |
| 34 | + pak::pkg_install(c( |
| 35 | + "readr", "dplyr", "tidyr", |
| 36 | + "lubridate", "fs", |
| 37 | + "github::hubverse-org/hubValidations")) |
| 38 | + shell: Rscript {0} |
| 39 | + - name: Pull ensemble csv files |
| 40 | + run: Rscript auxiliary-data/pull-flusight-ensembles.R |
| 41 | + - name: Show validation output in logs (for debugging) |
| 42 | + run: cat validation_result.md || echo "No validation_result.md found" |
| 43 | + - name: Read validation result |
| 44 | + id: validation |
| 45 | + run: | |
| 46 | + { |
| 47 | + echo 'body<<EOF' |
| 48 | + cat validation_result.md |
| 49 | + echo 'EOF' |
| 50 | + } >> "$GITHUB_OUTPUT" |
| 51 | + - name: Commit changes and create PR 🚀 |
| 52 | + if: ${{ inputs.publish || github.event_name == 'schedule' }} |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + run: | |
| 56 | + PR_DATETIME=$(date +'%Y-%m-%d_%H-%M-%S') |
| 57 | + git config user.name "github-actions[bot]" |
| 58 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 59 | + git checkout -b pull/ensembles/"$PR_DATETIME" |
| 60 | + git add . |
| 61 | + git commit -m "Pull ensemble forecasts" |
| 62 | + git push --set-upstream origin pull/ensembles/"$PR_DATETIME" |
| 63 | + gh pr create --title "Add new ensemble forecasts" \ |
| 64 | + --body "${{ steps.validation.outputs.body }}" \ |
| 65 | + --base main \ |
| 66 | + --head pull/ensembles/"$PR_DATETIME" |
| 67 | + shell: bash |
0 commit comments