update #2054
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 | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 6,12 * * *" | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
env: | |
S3_FOLDER: covid-19-excess-deaths-global-estimates-tracker | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
R_VERSION: 4.0.3 | |
NODE_VERSION: 16 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Set up R | |
uses: r-lib/actions/setup-r@12d5b556c504a4be89f0dc9779e0de65bf0cfa44 | |
with: | |
r-version: ${{ env.R_VERSION }} | |
- name: Set up Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Set up Ubuntu packages | |
# run: sudo apt-get install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev | |
run: sudo apt-get install libcurl4-openssl-dev libssl-dev libfontconfig1-dev libxml2-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev | |
- name: Cache R packages | |
id: cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: r-v5-${{ env.R_VERSION }} | |
restore-keys: r-v5 | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install packages | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
install.packages(c( | |
"devtools", | |
"anytime", | |
"countrycode", | |
"data.table", | |
"tidyverse", | |
"readxl", | |
"googlesheets4", | |
"lubridate", | |
"maps", | |
"progress", | |
"WDI", | |
"zoo" | |
)) | |
devtools::install_github('sondreus/agtboost/R-package') | |
shell: Rscript {0} | |
- name: Run R script | |
run: | | |
source('scripts/0_excess_deaths_global_estimates_autoupdater_A.R') | |
shell: Rscript {0} | |
- name: Run R script | |
run: | | |
source('scripts/0_excess_deaths_global_estimates_autoupdater_B_I.R') | |
shell: Rscript {0} | |
- name: Run R script | |
run: | | |
source('scripts/0_excess_deaths_global_estimates_autoupdater_B_II.R') | |
shell: Rscript {0} | |
- name: Run R script | |
run: | | |
source('scripts/4_excess_deaths_global_estimates_export_for_interactive.R') | |
shell: Rscript {0} | |
- name: Generate minimaps | |
run: | | |
cd scripts/minimaps && npm ci | |
npm run build | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit --allow-empty -m "Data auto-update" -a | |
- name: Push changes | |
uses: ad-m/github-push-action@8407731efefc0d8f72af254c74276b7a90be36e1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: Upload to S3 | |
run: | | |
aws s3 sync ./output-data/output-for-interactive s3://"$AWS_S3_BUCKET"/"$S3_FOLDER" --acl public-read --cache-control "public,max-age=300,proxy-revalidate" | |
env: | |
S3_FOLDER: ${{ env.S3_FOLDER }} | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'us-east-1' | |
- name: Create Cloudfront invalidation | |
run: | | |
aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_DISTRIBUTION_ID" --paths "/$S3_FOLDER/*" | |
env: | |
S3_FOLDER: ${{ env.S3_FOLDER }} | |
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'us-east-1' |