Promote Apps #72
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: Promote Apps | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
SKIP_REGRESSION: | |
description: Flag indicating if regression should be skipped. | |
type: boolean | |
required: false | |
default: false | |
APPS: | |
description: APPS to promote. | |
required: false | |
jobs: | |
affected: | |
runs-on: ubuntu-22.04 | |
outputs: | |
affected_apps: ${{ steps.set_outputs.outputs.affected_apps }} | |
affected_apps_array: ${{ steps.set_outputs.outputs.affected_apps_array }} | |
env: | |
AFFECTED_APPS: '' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
- run: npm ci | |
- name: Get last successful commit | |
uses: nrwl/nx-set-shas@v3 | |
id: last_successful_commit | |
with: | |
last-successful-event: workflow_dispatch | |
- name: Get affected apps | |
shell: bash | |
run: echo "AFFECTED_APPS=$(npx nx show projects --affected --type=app --base=${{ steps.last_successful_commit.outputs.base }} | tr "\n" " ")" >> $GITHUB_ENV | |
- name: Set outputs for downstream | |
id: set_outputs | |
shell: bash | |
run: | | |
echo "affected_apps=${{ github.event.inputs.APPS || env.AFFECTED_APPS }}" >> $GITHUB_OUTPUT | |
echo "affected_apps_array=$(echo ${{ github.event.inputs.APPS || env.AFFECTED_APPS }} | sed -e "s/ /\",\"/g" -e "s/^/[\"/" -e "s/$/\"]/")" >> $GITHUB_OUTPUT | |
stagingRegression: | |
runs-on: ubuntu-22.04 | |
needs: affected | |
if: needs.affected.outputs.affected_apps | |
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 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
- name: E2E Test | |
uses: ./.github/actions/nx-cypress-e2e | |
if: github.event.inputs.SKIP_REGRESSION != 'true' | |
with: | |
app: ${{ matrix.app }} | |
environment: staging | |
tags: '@regression 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 }} | |
deployProduction: | |
runs-on: ubuntu-22.04 | |
needs: [affected, stagingRegression] | |
strategy: | |
fail-fast: true | |
max-parallel: 2 | |
matrix: | |
app: ${{ fromJson(needs.affected.outputs.affected_apps_array) }} | |
environment: | |
name: Production | |
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 Production | |
run: oc tag ${{ matrix.app }}:uat ${{ matrix.app }}:prod --reference-policy='local' | |
- run: oc project adsp-prod | |
- name: Apply Manifests | |
run: | | |
oc process -f .openshift/managed/${{ matrix.app }}.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-prod -p DEPLOY_TAG=prod > ${{ matrix.app }}.prod.json | |
oc apply -f ${{ matrix.app }}.prod.json -l apply-prod=true,component!=database | |
- name: Deploy Production | |
run: | | |
oc rollout latest dc/${{ matrix.app }} | |
oc rollout status dc/${{ matrix.app }} | |
smokeTestProd: | |
runs-on: ubuntu-22.04 | |
needs: deployProduction | |
environment: | |
name: Prod-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 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
- name: E2E Test | |
uses: ./.github/actions/nx-cypress-e2e | |
with: | |
app: ${{ matrix.app }} | |
environment: prod | |
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 }} |