Skip to content

Merge pull request #3694 from GovAlta/CS-3634-c #4019

Merge pull request #3694 from GovAlta/CS-3634-c

Merge pull request #3694 from GovAlta/CS-3634-c #4019

Workflow file for this run

name: Delivery CI
on:
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
AFFECTED_BASE:
description: Value for --base= in nx affected commands
required: false
jobs:
build:
runs-on: ubuntu-22.04
outputs:
affected_apps: ${{ steps.set_outputs.outputs.affected_apps }}
affected_apps_array: ${{ steps.set_outputs.outputs.affected_apps_array }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '7'
- uses: actions/setup-java@v4
with:
java-version: '11'
distribution: temurin
cache: maven
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: snok/install-poetry@v1
with:
version: '1.6.1'
- run: npm ci
- name: Get last successful commit
id: last_successful_commit
uses: nrwl/nx-set-shas@v3
- name: Build
id: production-build
uses: ./.github/actions/nx-production-build
with:
affected-base: ${{ github.event.inputs.AFFECTED_BASE || steps.last_successful_commit.outputs.base }}
github_token: ${{ secrets.GITHUB_TOKEN }}
npm_token: ${{ secrets.NPM_TOKEN }}
- run: npm prune --production
- if: steps.production-build.outputs.affected-apps
run: tar czf adsp-build-dist.tar.gz node_modules/ dist/
- if: steps.production-build.outputs.affected-apps
uses: actions/upload-artifact@v4
with:
name: build-dist
path: adsp-build-dist.tar.gz
# Set build job outputs for subsequent jobs.
- id: set_outputs
run: |
echo "affected_apps=${{ steps.production-build.outputs.affected-apps }}" >> $GITHUB_OUTPUT
echo "affected_apps_array=$(echo ${{ steps.production-build.outputs.affected-apps }} | sed -e "s/ /\",\"/g" -e "s/^/[\"/" -e "s/$/\"]/")" >> $GITHUB_OUTPUT
buildContainers:
runs-on: ubuntu-24.04
needs: build
if: needs.build.outputs.affected_apps
strategy:
fail-fast: false
matrix:
app: ${{ fromJson(needs.build.outputs.affected_apps_array) }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: build-dist
path: ./
- run: tar -xf adsp-build-dist.tar.gz
- name: Build container
uses: ./.github/actions/build-publish-container
with:
app: ${{ matrix.app }}
redhat-io-username: ${{ secrets.REGISTRY_REDHAT_IO_USER }}
redhat-io-password: ${{ secrets.REGISTRY_REDHAT_IO_PASSWORD }}
build-context: ${{ hashFiles(format('./dist/apps/{0}/nginx.conf', matrix.app)) && format('./dist/apps/{0}', matrix.app) || './' }}
container-file: ${{ hashFiles(format('./apps/{0}/Dockerfile', matrix.app)) && format('./apps/{0}/Dockerfile', matrix.app) || './.openshift/service/Dockerfile' }}
ghcr-token: ${{ secrets.GITHUB_TOKEN }}
deployDev:
runs-on: ubuntu-22.04
needs: [build, buildContainers]
strategy:
fail-fast: true
max-parallel: 2
matrix:
app: ${{ fromJson(needs.build.outputs.affected_apps_array) }}
environment:
name: Dev
steps:
- uses: actions/checkout@v4
- name: Oc login
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.ARO_SERVER }}
openshift_token: ${{ secrets.ARO_TOKEN }}
namespace: adsp-build
insecure_skip_tls_verify: true
- name: Tag Dev
run: |
oc import-image ghcr.io/govalta/${{ matrix.app }}:latest --reference-policy='local' --confirm
oc tag ${{ matrix.app }}:latest ${{ matrix.app }}:dev --reference-policy='local'
- run: oc project adsp-dev
- name: Apply Manifests
run: |
oc process -f .openshift/managed/${{ matrix.app }}.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-dev -p DEPLOY_TAG=dev > ${{ matrix.app }}.dev.json
oc apply -f ${{ matrix.app }}.dev.json -l apply-dev=true,component!=database
- name: Deploy Dev
run: |
if oc get dc/${{ matrix.app }} ; then
oc rollout latest dc/${{ matrix.app }}
oc rollout status dc/${{ matrix.app }}
elif oc get deployment/${{ matrix.app }} ; then
oc set triggers deployment/${{ matrix.app }} --auto
oc rollout status deployment/${{ matrix.app }}
oc set triggers deployment/${{ matrix.app }} --manual
else
echo 'No DeploymentConfig or Deployment found for ${{ matrix.app }}.'
fi
devSmokeTest:
runs-on: ubuntu-22.04
needs: [build, deployDev]
environment:
name: Dev-e2e
strategy:
matrix:
app: [tenant-management-webapp, status-app, subscriber-app]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: E2E Test
uses: ./.github/actions/nx-cypress-e2e
with:
app: ${{ matrix.app }}
environment: dev
tags: '@smoke-test and not @ignore'
core-api-client-secret: ${{ secrets.CY_CORE_API_CLIENT_SECRET }}
core-api-user-password: ${{ secrets.CY_CORE_API_USER_PASSWORD }}
api-client-secret: ${{ secrets.CY_CLIENT_SECRET }}
cy-password: ${{ secrets.CY_PASSWORD }}
cy-password-2: ${{ secrets.CY_PASSWORD2 }}
cy-password-3: ${{ secrets.CY_PASSWORD3 }}
deployStagingApproval:
runs-on: ubuntu-22.04
needs: [build, devSmokeTest]
environment:
name: Staging-gate
steps:
- run: echo "Staging deployment approved"
deployStaging:
runs-on: ubuntu-22.04
needs: [build, deployStagingApproval]
strategy:
fail-fast: true
max-parallel: 2
matrix:
app: ${{ fromJson(needs.build.outputs.affected_apps_array) }}
environment:
name: Staging
steps:
- uses: actions/checkout@v4
- name: Oc login
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.ARO_SERVER }}
openshift_token: ${{ secrets.ARO_TOKEN }}
namespace: adsp-build
insecure_skip_tls_verify: true
- name: Tag Staging
run: oc tag ${{ matrix.app }}:dev ${{ matrix.app }}:uat --reference-policy='local'
- run: oc project adsp-uat
- name: Apply Manifests
run: |
oc process -f .openshift/managed/${{ matrix.app }}.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-uat -p DEPLOY_TAG=uat > ${{ matrix.app }}.uat.json
oc apply -f ${{ matrix.app }}.uat.json -l apply-staging=true,component!=database
- name: Deploy Staging
run: |
if oc get dc/${{ matrix.app }} ; then
oc rollout latest dc/${{ matrix.app }}
oc rollout status dc/${{ matrix.app }}
elif oc get deployment/${{ matrix.app }} ; then
oc set triggers deployment/${{ matrix.app }} --auto
oc rollout status deployment/${{ matrix.app }}
oc set triggers deployment/${{ matrix.app }} --manual
else
echo 'No DeploymentConfig or Deployment found for ${{ matrix.app }}.'
fi
stagingSmokeTest:
runs-on: ubuntu-22.04
needs: [build, deployStaging]
environment:
name: Staging-e2e
strategy:
matrix:
app: [tenant-management-webapp, status-app, subscriber-app]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: E2E Test
uses: ./.github/actions/nx-cypress-e2e
with:
app: ${{ matrix.app }}
environment: staging
tags: '@smoke-test and not @ignore'
core-api-client-secret: ${{ secrets.CY_CORE_API_CLIENT_SECRET }}
core-api-user-password: ${{ secrets.CY_CORE_API_USER_PASSWORD }}
api-client-secret: ${{ secrets.CY_CLIENT_SECRET }}
cy-password: ${{ secrets.CY_PASSWORD }}
cy-password-2: ${{ secrets.CY_PASSWORD2 }}
cy-password-3: ${{ secrets.CY_PASSWORD3 }}