Skip to content

Commit 7cd3e74

Browse files
committed
Reapply "combine seed and data reset jobs"
This reverts commit 6651d6b.
1 parent 6651d6b commit 7cd3e74

File tree

3 files changed

+69
-115
lines changed

3 files changed

+69
-115
lines changed

.github/workflows/clear-environment.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ jobs:
151151
) |
152152
.[]' <<< "$VARS_JSON_WITH_NEWLINES"
153153
)
154-
154+
155155
- name: Use Node.js 18
156156
uses: actions/setup-node@v4
157157
with:
158158
node-version: 18
159-
159+
160160
- name: Download images for ${{ inputs.stack }}
161161
run: |
162162
cd ./${{ github.event.repository.name }}
@@ -304,18 +304,8 @@ jobs:
304304
--country_config_version=${{ inputs.countryconfig-image-tag }} \
305305
--replicas=${{ vars.REPLICAS }}
306306
307-
reset:
308-
needs: deploy
309-
if: ${{ inputs.reset == 'true' && needs.deploy.outputs.outcome == 'success' }}
310-
uses: ./.github/workflows/clear-environment.yml
311-
with:
312-
environment: ${{ inputs.stack }}
313-
stack: ${{ inputs.stack }}
314-
secrets: inherit
315-
316307
seed-data:
317-
needs: reset
318-
if: ${{ inputs.reset == 'true' && needs.reset.outputs.outcome == 'success' }}
308+
needs: deploy
319309
uses: ./.github/workflows/seed-data.yml
320310
with:
321311
environment: ${{ inputs.stack }}

.github/workflows/seed-data.yml

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,70 @@ jobs:
3535
outcome: ${{ steps.seed.outcome }}
3636
timeout-minutes: 60
3737
steps:
38-
- name: Pull the seed-data image
39-
run: docker pull ghcr.io/opencrvs/ocrvs-data-seeder:${{ inputs.core-image-tag }}
38+
- name: Clone country config resource package
39+
uses: actions/checkout@v3
40+
with:
41+
fetch-depth: 1
42+
path: './${{ github.event.repository.name }}'
4043

41-
- name: Run docker container
42-
id: seed
43-
run: |
44-
docker run \
45-
-e ACTIVATE_USERS=${{ vars.ACTIVATE_USERS }} \
46-
-e GATEWAY_HOST="https://gateway.${{inputs.stack}}.opencrvs.dev" \
47-
-e AUTH_HOST="https://auth.${{inputs.stack}}.opencrvs.dev" \
48-
-e COUNTRY_CONFIG_HOST="https://countryconfig.${{inputs.stack}}.opencrvs.dev" \
49-
-e SUPER_USER_PASSWORD=${{ secrets.SUPER_USER_PASSWORD }} \
50-
ghcr.io/opencrvs/ocrvs-data-seeder:${{ inputs.core-image-tag }}
44+
- name: Read known hosts
45+
run: |
46+
cd ${{ github.event.repository.name }}
47+
echo "KNOWN_HOSTS<<EOF" >> $GITHUB_ENV
48+
sed -i -e '$a\' ./infrastructure/known-hosts
49+
cat ./infrastructure/known-hosts >> $GITHUB_ENV
50+
echo "EOF" >> $GITHUB_ENV
51+
52+
- name: Install SSH Key
53+
uses: shimataro/ssh-key-action@v2
54+
with:
55+
key: ${{ secrets.SSH_KEY }}
56+
known_hosts: ${{ env.KNOWN_HOSTS }}
57+
58+
- name: Reset data
59+
id: reset-data
60+
env:
61+
HOST: ${{ vars.DOMAIN }}
62+
ENV: ${{ vars.ENVIRONMENT_TYPE }}
63+
SSH_USER: ${{ secrets.SSH_USER }}
64+
# SSH_HOST was moved from a secret to a variable in OpenCRVS 1.5.0
65+
# @todo @deprecated remove the fallback to secrets.SSH_HOST in OpenCRVS 1.7.0
66+
SSH_HOST: ${{ vars.SSH_HOST || secrets.SSH_HOST }}
67+
# SSH_PORT was moved from a secret to a variable in OpenCRVS 1.5.0
68+
# @todo @deprecated remove the fallback to secrets.SSH_PORT in OpenCRVS 1.7.0
69+
SSH_PORT: ${{ vars.SSH_PORT || secrets.SSH_PORT }}
70+
REPLICAS: ${{ vars.REPLICAS }}
71+
MONGODB_ADMIN_USER: ${{ secrets.MONGODB_ADMIN_USER }}
72+
MONGODB_ADMIN_PASSWORD: ${{ secrets.MONGODB_ADMIN_PASSWORD }}
73+
ELASTICSEARCH_SUPERUSER_PASSWORD: ${{ secrets.ELASTICSEARCH_SUPERUSER_PASSWORD }}
74+
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
75+
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
76+
SSH_ARGS: ${{ vars.SSH_ARGS }}
77+
run: |
78+
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $SSH_ARGS "
79+
ELASTICSEARCH_ADMIN_USER=elastic \
80+
ELASTICSEARCH_ADMIN_PASSWORD=$ELASTICSEARCH_SUPERUSER_PASSWORD \
81+
MONGODB_ADMIN_USER=$MONGODB_ADMIN_USER \
82+
MONGODB_ADMIN_PASSWORD=$MONGODB_ADMIN_PASSWORD \
83+
MINIO_ROOT_USER=$MINIO_ROOT_USER \
84+
MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD \
85+
/opt/opencrvs/${{ inputs.stack }}/infrastructure/clear-all-data.sh $REPLICAS ${{ inputs.stack }}"
86+
87+
echo "Running migrations..."
88+
echo
89+
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $SSH_ARGS "
90+
/opt/opencrvs/${{ inputs.stack }}/infrastructure/run-migrations.sh ${{ inputs.stack }}"
91+
92+
- name: Pull the seed-data image
93+
run: docker pull ghcr.io/opencrvs/ocrvs-data-seeder:${{ inputs.core-image-tag }}
94+
95+
- name: Run docker container
96+
id: seed
97+
run: |
98+
docker run \
99+
-e ACTIVATE_USERS=${{ vars.ACTIVATE_USERS }} \
100+
-e GATEWAY_HOST="https://gateway.${{inputs.stack}}.opencrvs.dev" \
101+
-e AUTH_HOST="https://auth.${{inputs.stack}}.opencrvs.dev" \
102+
-e COUNTRY_CONFIG_HOST="https://countryconfig.${{inputs.stack}}.opencrvs.dev" \
103+
-e SUPER_USER_PASSWORD=${{ secrets.SUPER_USER_PASSWORD }} \
104+
ghcr.io/opencrvs/ocrvs-data-seeder:${{ inputs.core-image-tag }}

0 commit comments

Comments
 (0)