-
Notifications
You must be signed in to change notification settings - Fork 354
68 lines (58 loc) · 2.73 KB
/
deploy-instance.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
name: Deploy instance
on:
pull_request:
types: [opened, reopened, labeled, synchronize]
# Cancel previous runs of the same workflow and PR number or branch/tag
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
deploy-instance:
if: contains(github.event.pull_request.labels.*.name, 'deploy')
runs-on: ubuntu-latest
env:
HTTP: https --check-status
USER_EMAIL: ${{ secrets.IM_BOT_EMAIL }}
PASSWORD: ${{ secrets.IM_BOT_PASSWORD }}
IM_HOST: 'https://api.im.dhis2.org'
INSTANCE_HOST: 'https://dev.im.dhis2.org'
INSTANCE_NAME: pr-${{ github.event.pull_request.number }}
steps:
- name: Dump context
uses: crazy-max/ghaction-dump-context@v2
- name: Wait for API tests
# Using this fork of the upstream https://github.com/lewagon/wait-on-check-action,
# as it will filter out and check only the latest run of a workflow when checking for the allowed conclusions,
# instead of checking all of the re-runs and possibly failing due to skipped or cancelled runs.
# See https://github.com/lewagon/wait-on-check-action/issues/85 for more info.
uses: t3chguy/wait-on-check-action@master
with:
ref: ${{ github.head_ref }}
check-name: 'api-test'
repo-token: ${{ secrets.GITHUB_TOKEN }}
allowed-conclusions: success
- uses: actions/checkout@v4
with:
repository: dhis2-sre/im-manager
sparse-checkout: scripts/instances
- name: Install HTTPie
run: python -m pip install httpie
- name: Deploy DHIS2 instance
working-directory: scripts/instances
env:
IMAGE_REPOSITORY: core-pr
IMAGE_TAG: ${{ github.event.pull_request.number }}
IMAGE_PULL_POLICY: Always
DATABASE_ID: test-dbs-sierra-leone-dev-sql-gz
run: ./findByName.sh dev $INSTANCE_NAME && ./restart.sh dev $INSTANCE_NAME || ./deploy-dhis2.sh dev $INSTANCE_NAME
- name: Wait for instance
working-directory: scripts/instances
env:
EXPECTED_STATUS: Running
run: timeout 600 bash -ex -c 'until [[ "$(./status.sh dev $INSTANCE_NAME | jq -r)" == "$EXPECTED_STATUS" ]]; do echo "Instance is not $EXPECTED_STATUS yet ..."; sleep 5; done'
- name: Start analytics generation
run: curl -X POST -u "${{ secrets.DHIS2_USERNAME }}:${{ secrets.DHIS2_PASSWORD }}" "$INSTANCE_HOST/$INSTANCE_NAME/api/resourceTables/analytics" -d 'executeTei=true'
- name: Comment instance URL
uses: actions-cool/maintain-one-comment@v3
with:
body: "Instance deployed to https://dev.im.dhis2.org/pr-${{ github.event.pull_request.number }}"