-
Notifications
You must be signed in to change notification settings - Fork 83
118 lines (105 loc) · 3.88 KB
/
retrain.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: retrain
on:
workflow_dispatch:
schedule:
- cron: "0 00 * * 1"
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_C.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'