generated from hubverse-org/hubTemplate
-
Notifications
You must be signed in to change notification settings - Fork 12
58 lines (52 loc) · 1.62 KB
/
copy_hub-config.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
name: Copy updated files to hub-config
on:
push:
branches:
- main
paths:
- 'hub-config/**'
workflow_dispatch:
jobs:
copy-files:
runs-on: ubuntu-latest
steps:
- name: Checkout current repo
uses: actions/checkout@v2
with:
path: source
- name: Checkout target repo
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
- name: Compare and copy updated files
run: |
set -x
diff -qr source/hub-config/ rsv-forecast-hub_data/hub-config/ || true
DIFF_OUTPUT=$(diff -qr source/hub-config/ rsv-forecast-hub_data/hub-config/ || true)
FILES=$(echo "$DIFF_OUTPUT" | grep -o 'source/hub-config/.*' | cut -d ' ' -f 1)
cd source
for FILE in $FILES
do
FILE=${FILE#source/}
mkdir -p ../rsv-forecast-hub_data/$(dirname $FILE)
cp $FILE ../rsv-forecast-hub_data/$FILE || echo "Failed to copy $FILE"
done
shell: bash
- name: Commit and push changes
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"
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Upload new files to RSV data repo"
git push
echo "hub-config data uploaded";
else
echo "no upload";
fi
shell: bash