generated from hubverse-org/hubTemplate
-
Notifications
You must be signed in to change notification settings - Fork 11
145 lines (140 loc) · 5.78 KB
/
after-validate-submission.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: After Validate Submission Workflow
on:
#workflow_run:
# workflows: ["Hub Submission Validation (R)"] # The name of the workflow we want to trigger from
# types:
# - completed
pull_request_target:
types:
- closed
jobs:
copy-files-to-rsv-data-repo:
runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
if: github.event.pull_request.merged == true
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: r-lib/actions/setup-r@v2
with:
install-r: false
use-public-rspm: true
- name: Get list of changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Print changed files
run: |
echo 'Changed files: ${{ steps.changed-files.outputs.added_files }}'
echo 'Modified files: ${{ steps.changed-files.outputs.modified_files }}'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev
- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ hashFiles('DESCRIPTION') }}
restore-keys: ${{ runner.os }}-r-
- name: Install gh package
run: Rscript -e 'install.packages("gh")'
- name: Install here package
run: Rscript -e 'install.packages("here")'
- name: Install readr package
run: Rscript -e 'install.packages("readr")'
- name: Install lubridate package
run: Rscript -e 'install.packages("lubridate")'
- name: Install ggridges package
run: Rscript -e 'install.packages("ggridges")'
- name: Install forcats package
run: Rscript -e 'install.packages("forcats")'
- name: Install arrow package
run: Rscript -e 'install.packages("arrow")'
- name: Install dplyr package
run: Rscript -e 'install.packages("dplyr")'
- name: Install jsonlite package
run: Rscript -e 'install.packages("jsonlite")'
- name: Install purrr package
run: Rscript -e 'install.packages("purrr")'
- name: Install hubViz
run: |
Rscript -e 'install.packages("remotes")'
Rscript -e 'remotes::install_github("hubverse-org/hubVis")'
- name: Install hubUtils
run: |
Rscript -e 'remotes::install_github("kjsato/hubUtils@main-mr_schema", upgrade = "never")'
- name: Install hubEnsembles
run: |
Rscript -e 'remotes::install_github("hubverse-org/hubEnsembles")'
- name: Install hubData
run: |
Rscript -e 'remotes::install_github("kjsato/hubData@main-mr_schema", upgrade = "never")'
- name: Check if RETRO files are present
id: check_files
run: |
echo 'retro='$(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | tr ' ' '\n' | grep 'model-output' | grep '.*-RETRO.*\.\(csv\|parquet\)'| grep -v '\.github/') >> $GITHUB_ENV
echo 'conventional='$(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | tr ' ' '\n' | grep -v '\.github/' | grep -c -v '.*-RETRO.*\.\(csv\|parquet\)') >> $GITHUB_ENV
- name: Run R script
run: |
cd ./scripts
Rscript ensemble.R
if: ${{ env.conventional != '0' }}
- name: Run retro_ensemble.R
run: |
cd ./scripts
for file in $(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | tr ' ' '\n' | grep 'model-output' | grep '.*-RETRO.*\.\(csv\|parquet\)'| grep -v '\.github/'); do
echo "Processing file: $file"
Rscript retro_ensemble.R $file
done
if: ${{ env.retro != '0' }}
- name: Commit and push new files to root repository
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if [ -n "$(git status --porcelain)" ]; then
git add model-output/hub-ensemble/*
git commit -m "Upload new files to RSV data repo by ${GITHUB_ACTOR} in #${{ github.event.pull_request.number }}"
git push
echo "Data for hub-ensemble uploaded to root repo";
else
echo "no upload for root repo";
fi
shell: bash
- name: Checkout and push to another repository
uses: actions/checkout@v2
with:
repository: HopkinsIDD/rsv-forecast-hub_data
#repository: kjsato/rsv-forecast-hub_data
token: ${{ secrets.KJ3_PATC }}
path: ./rsv-forecast-hub_data
fetch-depth: 2
ref: main
- name: Copy new files
run: |
for FILE in model-output/**/* model-metadata/*; do
if [ -f "$FILE" ]; then
mkdir -p ./rsv-forecast-hub_data/$(dirname $FILE)
cp $FILE ./rsv-forecast-hub_data/$FILE
fi
done
- name: Commit and push new files
run: |
cd ./rsv-forecast-hub_data
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git pull origin main
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Upload new files to RSV data repo by ${GITHUB_ACTOR} in #${{ github.event.pull_request.number }}"
git push
echo "RSV data uploaded";
else
echo "no upload";
fi
shell: bash