-
Notifications
You must be signed in to change notification settings - Fork 9
80 lines (70 loc) · 2.6 KB
/
autofill.yml
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
name: Autofill & Build
on:
pull_request_target:
branches: [ master ]
jobs:
autofill_and_build:
runs-on: ubuntu-latest
services:
covid-drdb-devdb:
image: postgres:latest
env:
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout payload repository
uses: actions/checkout@v3
with:
path: covid-drdb-payload
- name: Checkout covid-drdb repository
uses: actions/checkout@v3
with:
repository: hivdb/covid-drdb
path: covid-drdb
- name: Checkout PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd covid-drdb-payload
gh pr checkout ${{ github.event.pull_request.number }}
- name: Run autofill-payload
run: |
set -e
cd covid-drdb
docker run --rm -v $GITHUB_WORKSPACE/covid-drdb:/covid-drdb -v $GITHUB_WORKSPACE/covid-drdb-payload:/covid-drdb-payload hivdb/covid-drdb-builder:latest pipenv run python -m drdb.entry autofill-payload /covid-drdb-payload
- name: Validate the results
env:
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
run: |
set -e
cd covid-drdb
mkdir -p local/sqls
docker run --rm -v="$(pwd)":/covid-drdb/ -v="$(dirname $(pwd))"/covid-drdb-payload:/covid-drdb/payload hivdb/covid-drdb-builder:latest scripts/export-sqls.sh
psql -v ON_ERROR_STOP=1 -U postgres -h localhost -f local/sqls/01_schema.sql
psql -v ON_ERROR_STOP=1 -U postgres -h localhost -f local/sqls/02_data_tables.sql
psql -v ON_ERROR_STOP=1 -U postgres -h localhost -f local/sqls/03_derived_tables.sql
- name: Check for changes and commit
run: |
git config --global user.name "HIVDB Bot"
git config --global user.email "[email protected]"
cd covid-drdb-payload
git add .
git diff --cached --quiet || git commit -m "Autogenerated data updated by HIVDB Bot"
echo "committed=$?" >> $GITHUB_ENV
- name: Push changes
if: env.committed == 0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
cd covid-drdb-payload
git remote add headrepo https://${GITHUB_TOKEN}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git
git push headrepo ${{ github.event.pull_request.head.ref }}
gh pr edit ${{ github.event.pull_request.number }} --add-label "autofilled"