|
1 | 1 | name: Reset environment |
2 | 2 | run-name: "Reset ${{ inputs.environment }} environment" |
3 | 3 | 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 |
14 | 20 | jobs: |
15 | 21 | prepare: |
16 | 22 | outputs: |
@@ -58,37 +64,49 @@ jobs: |
58 | 64 | matrix: |
59 | 65 | job-name: |
60 | 66 | - data-cleanup |
61 | | - - postgres-on-update-core |
62 | | - - postgres-on-update-analytics |
| 67 | + - postgres-on-deploy |
| 68 | + - data-migration-analytics |
63 | 69 | - data-migration |
64 | 70 | - data-seed |
65 | 71 | - elasticsearch-reindex |
66 | 72 | 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