test fix #2221
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-20.04 | |
outputs: | |
affected_apps: ${{ steps.set_outputs.outputs.affected_apps }} | |
affected_apps_array: ${{ steps.set_outputs.outputs.affected_apps_array }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '7' | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: temurin | |
cache: maven | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- uses: snok/install-poetry@v1 | |
with: | |
version: '1.4.0' | |
- 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@v3 | |
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-20.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@v3 | |
- uses: actions/download-artifact@v3 | |
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-20.04 | |
needs: [build, buildContainers] | |
env: | |
AFFECTED_APPS: ${{ needs.build.outputs.affected_apps }} | |
environment: | |
name: Dev | |
steps: | |
- uses: actions/checkout@v3 | |
- 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: | | |
for app in $AFFECTED_APPS | |
do | |
oc import-image ghcr.io/govalta/$app:latest --reference-policy='local' --confirm | |
oc tag $app:latest $app:dev --reference-policy='local' | |
done | |
- run: oc project adsp-dev | |
- name: Apply Manifests | |
run: | | |
for app in $AFFECTED_APPS | |
do | |
oc process -f .openshift/managed/$app.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-dev -p DEPLOY_TAG=dev > $app.dev.json | |
oc apply -f $app.dev.json -l apply-dev=true,component!=database | |
done | |
- name: Deploy Dev | |
run: | | |
for app in $AFFECTED_APPS | |
do | |
oc rollout latest dc/$app | |
oc rollout status dc/$app | |
done | |
devSmokeTest: | |
runs-on: ubuntu-20.04 | |
needs: [build, deployDev] | |
environment: | |
name: Dev-e2e | |
strategy: | |
matrix: | |
app: [tenant-management-webapp, status-app, subscriber-app] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
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 }} | |
deployStaging: | |
runs-on: ubuntu-20.04 | |
needs: [build, devSmokeTest] | |
env: | |
AFFECTED_APPS: ${{ needs.build.outputs.affected_apps }} | |
environment: | |
name: Staging | |
steps: | |
- uses: actions/checkout@v3 | |
- 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: | | |
for app in $AFFECTED_APPS | |
do | |
oc tag $app:dev $app:uat --reference-policy='local' | |
done | |
- run: oc project adsp-uat | |
- name: Apply Manifests | |
run: | | |
for app in $AFFECTED_APPS | |
do | |
oc process -f .openshift/managed/$app.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-uat -p DEPLOY_TAG=uat > $app.uat.json | |
oc apply -f $app.uat.json -l apply-staging=true,component!=database | |
done | |
- name: Deploy Staging | |
run: | | |
for app in $AFFECTED_APPS | |
do | |
oc rollout latest dc/$app | |
oc rollout status dc/$app | |
done | |
stagingSmokeTest: | |
runs-on: ubuntu-20.04 | |
needs: [build, deployStaging] | |
environment: | |
name: Staging-e2e | |
strategy: | |
matrix: | |
app: [tenant-management-webapp, status-app, subscriber-app] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
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 }} |