Skip to content

Commit 583437f

Browse files
committed
feat: Allow using custom helm charts from custom branch
1 parent 61a9d73 commit 583437f

File tree

2 files changed

+59
-40
lines changed

2 files changed

+59
-40
lines changed

.github/workflows/k8s-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,5 @@ jobs:
143143
uses: ./.github/workflows/k8s-reset-data.yml
144144
with:
145145
environment: ${{ inputs.environment }}
146+
chart-branch: ${{ inputs.chart-branch }}
146147
secrets: inherit
Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
name: Reset environment
22
run-name: "Reset ${{ inputs.environment }} environment"
33
on:
4-
workflow_dispatch:
5-
inputs:
6-
environment:
7-
description: "Target environment"
8-
required: true
9-
type: string
10-
workflow_call:
11-
inputs:
12-
environment:
13-
type: string
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: "Target environment"
8+
required: true
9+
type: string
10+
chart-branch:
11+
description: 'Helm chart version to deploy'
12+
required: false
13+
default: 'develop'
14+
workflow_call:
15+
inputs:
16+
environment:
17+
type: string
18+
chart-branch:
19+
type: string
1420
jobs:
1521
prepare:
1622
outputs:
@@ -58,37 +64,49 @@ jobs:
5864
matrix:
5965
job-name:
6066
- data-cleanup
61-
- postgres-on-update-core
62-
- postgres-on-update-analytics
67+
- postgres-on-deploy
68+
- data-migration-analytics
6369
- data-migration
6470
- data-seed
6571
- elasticsearch-reindex
6672
steps:
67-
- name: Download helm release values file into /tmp/opencrvs-${{ inputs.environment }}.json
68-
uses: actions/download-artifact@v4
69-
with:
70-
name: opencrvs-${{ inputs.environment }}-values-file
71-
path: /tmp
72-
- name: Create job ${{ matrix.job-name }} from helm template and apply it
73-
run: |
74-
kubectl delete job -n ${namespace} --ignore-not-found=true ${{ matrix.job-name }}
75-
helm template -f ${{ needs.prepare.outputs.values-file }} \
76-
--set data_cleanup.enabled=true \
77-
--set data_seed.enabled=true \
78-
--namespace ${namespace} \
79-
-s templates/${{ matrix.job-name }}-job.yaml \
80-
oci://ghcr.io/opencrvs/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -
81-
- name: Checking ${{ matrix.job-name }} job status
82-
run: |
83-
while true; do
84-
kubectl wait --for=condition=ready pod -ljob-name=${{ matrix.job-name }} --timeout=300s -n ${namespace} && \
85-
kubectl logs job/${{ matrix.job-name }} --all-containers -f -n ${namespace} && \
86-
touch /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt || break;
87-
sleep 1; done &
88-
echo "---------------------- Waiting for job completion ----------------------"
89-
kubectl wait --for=condition=complete job/${{ matrix.job-name }} -n ${namespace} --timeout=600s; status=$? || true
90-
[ $status -ne 0 ] && kubectl get pods -n ${namespace} --show-labels && kubectl describe pod -ljob-name=${job_name} -n ${namespace};
91-
[ ! -f /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt ] && kubectl logs job/${{ matrix.job-name }} --all-containers -n ${namespace} || \
92-
rm -vf /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt
93-
kill %1 2>/dev/null && echo "Stopped log streaming" || true
94-
exit $status
73+
- name: Checkout repo
74+
uses: actions/checkout@v5
75+
# FIXME: Update to charts repository once available
76+
- name: Checkout infrastructure repository
77+
uses: actions/checkout@v5
78+
with:
79+
repository: opencrvs/infrastructure
80+
path: infrastructure
81+
ref: ${{ inputs.chart-branch }}
82+
- name: Verify branch status ${{ inputs.chart-branch }}
83+
working-directory: infrastructure
84+
run: git status
85+
- name: Download helm release values file into /tmp/opencrvs-${{ inputs.environment }}.json
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: opencrvs-${{ inputs.environment }}-values-file
89+
path: /tmp
90+
- name: Create job ${{ matrix.job-name }} from helm template and apply it
91+
run: |
92+
kubectl delete job -n ${namespace} --ignore-not-found=true ${{ matrix.job-name }}
93+
helm template -f ${{ needs.prepare.outputs.values-file }} \
94+
--set data_cleanup.enabled=true \
95+
--set data_seed.enabled=true \
96+
--namespace ${namespace} \
97+
-s templates/${{ matrix.job-name }}-job.yaml \
98+
infrastructure/charts/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -
99+
- name: Checking ${{ matrix.job-name }} job status
100+
run: |
101+
while true; do
102+
kubectl wait --for=condition=ready pod -ljob-name=${{ matrix.job-name }} --timeout=300s -n ${namespace} && \
103+
kubectl logs job/${{ matrix.job-name }} --all-containers -f -n ${namespace} && \
104+
touch /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt || break;
105+
sleep 1; done &
106+
echo "---------------------- Waiting for job completion ----------------------"
107+
kubectl wait --for=condition=complete job/${{ matrix.job-name }} -n ${namespace} --timeout=600s; status=$? || true
108+
[ $status -ne 0 ] && kubectl get pods -n ${namespace} --show-labels && kubectl describe pod -ljob-name=${job_name} -n ${namespace};
109+
[ ! -f /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt ] && kubectl logs job/${{ matrix.job-name }} --all-containers -n ${namespace} || \
110+
rm -vf /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt
111+
kill %1 2>/dev/null && echo "Stopped log streaming" || true
112+
exit $status

0 commit comments

Comments
 (0)