Skip to content

Commit 64695d0

Browse files
committed
fix: Dummy commit new workflows to allow testing (ocrvs-10785)
1 parent dc67e02 commit 64695d0

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy Dependencies (with approval)
2+
run-name: Deploy Dependencies on ${{ inputs.environment }}
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: "Target environment"
8+
required: true
9+
default: "dev"
10+
type: choice
11+
options:
12+
- ""
13+
jobs:
14+
github-to-k8s-sync-env:
15+
uses: ./.github/workflows/github-to-k8s-sync-env.yml
16+
with:
17+
environment: ${{ inputs.environment }}
18+
mapping_file: "deps"
19+
secrets: inherit
20+
deploy:
21+
needs: github-to-k8s-sync-env
22+
environment: ${{ inputs.environment }}
23+
env:
24+
ENV: ${{ inputs.environment }}
25+
runs-on:
26+
- self-hosted
27+
- k8s
28+
- ${{ inputs.environment }}
29+
steps:
30+
- name: checkout repository
31+
uses: actions/checkout@v5
32+
- name: Install traefik
33+
run: |
34+
kubectl scale deployment traefik --replicas=0 --namespace traefik || true
35+
helm upgrade --install traefik oci://ghcr.io/traefik/helm/traefik \
36+
--namespace traefik \
37+
--create-namespace \
38+
-f environments/${ENV}/traefik/values.yaml
39+
kubectl scale deployment traefik --replicas=1 --namespace traefik
40+
- name: Install OpenCRVS dependencies
41+
run: |
42+
helm upgrade --install opencrvs-deps oci://ghcr.io/opencrvs/opencrvs-dependencies-chart \
43+
--namespace "opencrvs-deps-${ENV}" \
44+
-f environments/${ENV}/dependencies/values.yaml \
45+
--create-namespace \
46+
--set hostname=${{ vars.DOMAIN }} \
47+
--atomic
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Deploy OpenCRVS (with approval)
2+
run-name: "Deploy OpenCRVS on ${{ inputs.environment }} (core: ${{ inputs.core-image-tag }}, country: ${{ inputs.countryconfig-image-tag }})"
3+
on:
4+
workflow_call:
5+
inputs:
6+
core-image-tag:
7+
type: string
8+
countryconfig-image-tag:
9+
type: string
10+
environment:
11+
type: string
12+
workflow_dispatch:
13+
inputs:
14+
core-image-tag:
15+
description: "Tag of the core image"
16+
required: true
17+
default: "v1.9.0-beta-1"
18+
countryconfig-image-tag:
19+
description: "Tag of the countryconfig image"
20+
required: true
21+
default: "v1.9.0-beta-1"
22+
environment:
23+
description: "Target environment"
24+
required: true
25+
default: "dev"
26+
type: choice
27+
options:
28+
- demo1
29+
jobs:
30+
github-to-k8s-sync-env:
31+
uses: ./.github/workflows/github-to-k8s-sync-env.yml
32+
with:
33+
environment: ${{ inputs.environment }}
34+
secrets: inherit
35+
deploy:
36+
needs: github-to-k8s-sync-env
37+
environment: ${{ inputs.environment }}
38+
env:
39+
ENV: ${{ inputs.environment }}
40+
BRANCH: ${{ github.ref_name }}
41+
CORE_IMAGE_TAG: ${{ inputs.core-image-tag }}
42+
COUNTRYCONFIG_IMAGE_TAG: ${{ inputs.countryconfig-image-tag }}
43+
COUNTRYCONFIG_IMAGE_NAME: ${{ secrets.DOCKERHUB_ACCOUNT || 'opencrvs' }}/${{ secrets.DOCKERHUB_REPO || 'ocrvs-farajaland'}}
44+
runs-on:
45+
- self-hosted
46+
- k8s
47+
- ${{ inputs.environment }}
48+
steps:
49+
- uses: actions/checkout@v5
50+
- name: Generate summary
51+
env:
52+
PUBLIC_DOMAIN: ${{ vars.DOMAIN }}
53+
run: |
54+
SUMMARY=$(cat <<EOF
55+
### Deployment Summary
56+
57+
| Key | Value |
58+
|-----|-------|
59+
| Environment URL | https://$PUBLIC_DOMAIN |
60+
| Core image tag | \`${{ inputs.core-image-tag }}\` |
61+
| Country config image | \`${{ inputs.countryconfig-image-tag }}\` |
62+
| Branch name | \`${{ github.ref_name }}\` |
63+
EOF
64+
)
65+
echo "$SUMMARY" | sed 's/^ //' >> $GITHUB_STEP_SUMMARY
66+
- name: Create namespace
67+
run: kubectl create namespace "opencrvs-${ENV}" || true
68+
- name: Copy secrets from dependencies into application namespace
69+
# Only redis secret for now needs to be copied
70+
run: |
71+
secrets=(
72+
"redis-opencrvs-users"
73+
)
74+
for secret in "${secrets[@]}"; do
75+
kubectl get secret $secret -n opencrvs-deps-${ENV} -o yaml \
76+
| sed "s#namespace: opencrvs-deps-${ENV}#namespace: opencrvs-${ENV}#" \
77+
| grep -vE 'resourceVersion|uid|creationTimestamp' \
78+
| kubectl apply -n opencrvs-${ENV} -f - \
79+
|| echo "Secret $secret doesn't exist in opencrvs-deps-${ENV} namespace"
80+
done
81+
- name: Deploy with Helm
82+
run: |
83+
helm upgrade --install opencrvs oci://ghcr.io/opencrvs/opencrvs-services \
84+
--timeout 15m \
85+
--namespace "opencrvs-${ENV}" \
86+
-f environments/${ENV}/opencrvs-services/values.yaml \
87+
--create-namespace \
88+
--atomic \
89+
--debug \
90+
--wait \
91+
--wait-for-jobs \
92+
--set image.tag="$CORE_IMAGE_TAG" \
93+
--set countryconfig.image.tag="$COUNTRYCONFIG_IMAGE_TAG" \
94+
--set countryconfig.image.name="$COUNTRYCONFIG_IMAGE_NAME" \
95+
--set hostname=${{ vars.DOMAIN }} 2>&1 | sed '/USER-SUPPLIED VALUES:/,$d'; exit ${PIPESTATUS[0]};
96+
- name: Cleanup Helm Locks
97+
if: failure() || cancelled()
98+
run: |
99+
kubectl -n "opencrvs-${ENV}" get secrets -l owner=helm -o json | \
100+
jq -r '.items[] | select(.metadata.labels.status=="pending-install" or .metadata.labels.status=="pending-upgrade") | .metadata.name' | \
101+
xargs -r kubectl -n "opencrvs-${ENV}" delete secret || \
102+
echo "No helm locks found, all is good"

0 commit comments

Comments
 (0)