The Deploy Instance workflow automatically builds images and deploys them to the appropriate OpenShift instance whenever a commit lands on develop or main:
| Branch | Instance | Namespace | GH environment | Image tags |
|---|---|---|---|---|
develop |
bcgov-di-test |
fd34fb-test |
test |
bcgov-di-test (floating) |
main |
bcgov-di |
fd34fb-prod |
prod |
bcgov-di (floating) + bcgov-di-<sha12> (immutable, for rollback) |
This replaces the prior manual flow (local scripts/oc-deploy.sh + ad-hoc tag pushes via the now-retired build-apps.yml) for test and production deployments.
- Trigger:
pushtodevelopormain. - Metadata job resolves instance name, namespace, image tag(s), and GH environment based on which branch was pushed (see table above).
- Build job (parallel matrix):
backend-services,frontend,temporal. Each image is pushed to<artifactory>/kfd3-fd34fb-local/<service>:<tag>for every tag resolved by metadata — so prod builds push to both the floating tag and the SHA tag in one buildx invocation. - Deploy job:
- Generates a Kustomize overlay from
deployments/openshift/kustomize/overlays/instance-template, substituting instance/namespace/cluster-domain/image tags. oc applys the rendered manifests.- Creates/updates the
bcgov-di-test-artifactory-pullimage-pull secret, thebcgov-di-test-backend-services-secrets, andbcgov-di-test-temporal-worker-secretsfrom GitHub env secrets. - Helm-installs the per-instance PLG monitoring stack (Grafana/Loki/Prometheus).
oc rollout restarton all app deployments; the backend'smigrate-dbinit container runsprisma migrate deployon fresh-pod start. No separate migrate step.- Runs
scripts/artifactory-cleanup.sh --deleteto reclaim storage from orphansha256__*manifests left behind by the tag overwrite (non-blocking).
- Generates a Kustomize overlay from
The workflow uses a per-ref concurrency group with cancel-in-progress: true. If two commits land on the same branch in rapid succession, the older run is cancelled and the newer commit is deployed. Pushes to develop and main run independently.
| Target | Tag pattern | Rollback | Rotation |
|---|---|---|---|
Test (push to develop) |
bcgov-di-test (floating, single tag) |
Re-deploy a previous commit by rebuilding it | Overwritten on every push; orphan manifests garbage-collected post-deploy |
Prod (push to main) |
bcgov-di (floating) + bcgov-di-<sha12> (immutable) |
oc set image .../<svc>=<registry>/<svc>:bcgov-di-<old-sha12> |
Scheduled cleanup keeps the N most recent bcgov-di-* SHA tags and deletes the rest |
test— populated byscripts/gh-setup-test-env.sh(see below). All shared secrets mirrordev, withOPENSHIFT_*overridden forfd34fb-test.prod— already configured with production OpenShift and Azure/SSO secrets. Secrets sourced fromdeployments/openshift/config/prod.env+ thefd34fb-prodSA token.
Both environments should have:
OPENSHIFT_TOKEN— service-account token for the matching namespaceOPENSHIFT_NAMESPACE— literal namespace name (fd34fb-testorfd34fb-prod)OPENSHIFT_SERVER— cluster API URL (https://api.silver.devops.gov.bc.ca:6443)ARTIFACTORY_URL,ARTIFACTORY_SA_USERNAME,ARTIFACTORY_SA_PASSWORD- Azure, SSO, and app-config secrets as referenced in the workflow
One-time manual step: create a deploy SA in the fd34fb-test namespace with the same permissions as in fd34fb-prod. The existing scripts/oc-setup-sa.sh supports --env dev|prod today; for test it must be done manually until that script is extended (or we'll extract this into a workflow later).
Minimum: oc create serviceaccount deploy + oc policy add-role-to-user admin -z deploy + oc create token deploy --duration=8760h > .oc-deploy/token-fd34fb-test.
Run once, locally, after minting the test SA token:
./scripts/gh-setup-test-env.shThe script:
- Creates the GitHub
testenvironment (no protection rules). gh secret set -f deployments/openshift/config/dev.env --env testto bulk-load the shared secrets without printing values.- Extracts the
TOKEN=value from.oc-deploy/token-fd34fb-testand pipes it intogh secret set OPENSHIFT_TOKEN --env test. - Sets
OPENSHIFT_NAMESPACEandOPENSHIFT_SERVERto their test values.
Secret values never touch stdout.
The workflow supports manual dispatch from any branch with explicit inputs:
environment(dev|test|prod, defaultdev)environment(dev|test, defaultdev)namespace(optional OpenShift namespace override)instance_name(optional instance name override)
Manual-dispatch behavior:
- By default, instance and image tag are branch-derived (same as before).
- If
instance_nameis provided, it overrides the branch-derived instance name. - The selected
environmentis used as the GitHub environment for both build and deploy jobs, so environment-specific secrets (includingtest) are honored. - If
namespaceis not provided, deploy usesOPENSHIFT_NAMESPACEfrom the selected GitHub environment secrets.