-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (76 loc) · 3.24 KB
/
adp.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
name: adp
on:
schedule:
- cron: '*/20 * * * *'
workflow_dispatch:
jobs:
process-reference-files:
runs-on: ubuntu-latest
steps:
- name: check_out_contrib1_repository
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: 'ElectricNroff/test2'
path: 'data-contrib1'
- name: process_new_files_from_contrib1
env:
G_READ_API_KEY: ${{ secrets.G_READ_API_KEY }}
G_WRITE_API_KEY: ${{ secrets.G_WRITE_API_KEY }}
run: |
CONTRIBUTOR="contrib1"
DIR_IN_PRIMARY_REPO="ElectricNroff/test2"
CHECKOUT_PATH="data-$CONTRIBUTOR"
DIRECTORY="references"
cd $CHECKOUT_PATH
curl -s -S -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://raw.githubusercontent.com/ElectricNroff/data/main/actions-bin/create-file-via-api.py > create-file-via-api.py
curl -s -S -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://raw.githubusercontent.com/ElectricNroff/data/main/actions-bin/read-file-via-api.py > read-file-via-api.py
CURRENT_SHA=$(git rev-parse HEAD)
PREVIOUS_SHA=$(python read-file-via-api.py $DIR_IN_PRIMARY_REPO last_run_sha)
if [ -n "$PREVIOUS_SHA" ]; then
git diff --name-only --diff-filter=A $PREVIOUS_SHA $CURRENT_SHA $DIRECTORY | while read REFERENCE_FILE; do
echo "Processing: $REFERENCE_FILE"
python create-file-via-api.py $REFERENCE_FILE $CONTRIBUTOR
done
fi
- name: check_out_primary_repository
uses: actions/checkout@v3
with:
ref: 'main'
fetch-depth: 0
repository: 'ElectricNroff/data'
path: 'data-primary'
- name: process_new_files_from_primary
env:
A_API_KEY: ${{ secrets.A_API_KEY }}
run: |
DIR_IN_PRIMARY_REPO="ElectricNroff/data"
CHECKOUT_PATH="data-primary"
DIRECTORY="references"
PRIMARY_LAST_RUN_SHA="last_run_shas/$DIR_IN_PRIMARY_REPO/last_run_sha"
cd $CHECKOUT_PATH
CURRENT_SHA=$(git rev-parse HEAD)
PREVIOUS_SHA=$(cat $PRIMARY_LAST_RUN_SHA)
if [ -n "$PREVIOUS_SHA" ]; then
git diff --name-only --diff-filter=A $PREVIOUS_SHA $CURRENT_SHA $DIRECTORY | while read REFERENCE_FILE; do
echo "Processing: $REFERENCE_FILE"
python actions-bin/adp.py $CHECKOUT_PATH $DIRECTORY $REFERENCE_FILE
done
fi
echo $CURRENT_SHA > $PRIMARY_LAST_RUN_SHA
git config user.name "GitHub Action"
git config user.email "action@github.example.com"
git add $PRIMARY_LAST_RUN_SHA
THIS_CONTRIBUTOR="contrib1"
THIS_CONTRIBUTOR_REPO="ElectricNroff/test2"
CURRENT_SHA_OF_CONTRIBUTOR=$(cd ../data-$THIS_CONTRIBUTOR; git rev-parse HEAD)
CONTRIBUTOR_LAST_RUN_SHA="last_run_shas/$THIS_CONTRIBUTOR_REPO/last_run_sha"
echo $CURRENT_SHA_OF_CONTRIBUTOR > $CONTRIBUTOR_LAST_RUN_SHA
git add $CONTRIBUTOR_LAST_RUN_SHA
if [ -s .rbp ]; then
RBP_BASENAME=$(head -1 .rbp)
RBP_PATHNAME=rbp/$RBP_BASENAME
git add $RBP_PATHNAME
fi
git commit -m "Update last run SHA for primary"
git push