diff --git a/.github/workflows/pr-close.yml b/.github/workflows/pr-close.yml index 2eb103111..de5fd3d7b 100644 --- a/.github/workflows/pr-close.yml +++ b/.github/workflows/pr-close.yml @@ -10,11 +10,25 @@ concurrency: cancel-in-progress: true jobs: + setup: + name: Reset the deployment number + runs-on: ubuntu-22.04 + outputs: + zone: ${{ steps.calculate.outputs.zone }} + steps: + - name: Calculate the deployment number + id: calculate + run: | + echo "zone=$((${{ github.event.number }} % 50))" >> $GITHUB_OUTPUT + # Tag images for promotion on GitHub Container Registry (ghcr.io) image-promotions: name: Tag images if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' runs-on: ubuntu-22.04 + needs: setup + env: + ZONE: ${{ needs.setup.outputs.zone }} strategy: matrix: package: [api, admin, db, public] @@ -23,14 +37,16 @@ jobs: with: registry: ghcr.io repository: ${{ github.repository }}/${{ matrix.package }} - target: ${{ github.event.number }} + target: ${{ env.ZONE }} tags: test cleanup-openshift: name: Cleanup OpenShift runs-on: ubuntu-22.04 + needs: setup env: NAME: fom + ZONE: ${{ needs.setup.outputs.zone }} steps: - uses: actions/checkout@v3 - name: Remove OpenShift artifacts @@ -39,5 +55,5 @@ jobs: oc project ${{ vars.OC_NAMESPACE }} # Remove old build runs, build pods and deployment pods - oc delete all,pvc,secret,cm -l app=${{ env.NAME }}-${{ github.event.number }} + oc delete all,pvc,secret,cm -l app=${{ env.NAME }}-${{ env.ZONE }} diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 4f4a4c3fa..77046d809 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -8,11 +8,25 @@ concurrency: cancel-in-progress: true jobs: + setup: + name: Reset the deployment number + runs-on: ubuntu-22.04 + outputs: + zone: ${{ steps.calculate.outputs.zone }} + steps: + - name: Calculate the deployment number + id: calculate + run: | + echo "zone=$((${{ github.event.number }} % 50))" >> $GITHUB_OUTPUT + prep: name: Prep permissions: pull-requests: write runs-on: ubuntu-22.04 + needs: setup + env: + ZONE: ${{ needs.setup.outputs.zone }} steps: - name: PR Greeting if: github.event.action == 'opened' || github.event.action == 'reopened' @@ -26,9 +40,9 @@ jobs: Thanks for the PR! Any successful deployments (not always required) will be available below. - - [api](https://fom-${{ github.event.number }}.${{ env.DOMAIN }}/api) - - [admin](https://fom-${{ github.event.number }}.${{ env.DOMAIN }}/admin) - - [public](https://fom-${{ github.event.number }}.${{ env.DOMAIN }}/public) + - [api](https://fom-${{ env.ZONE }}.${{ env.DOMAIN }}/api) + - [admin](https://fom-${{ env.ZONE }}.${{ env.DOMAIN }}/admin) + - [public](https://fom-${{ env.ZONE }}.${{ env.DOMAIN }}/public) Once merged, code will be promoted and handed off to following workflow run. - [Main Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge-main.yml) @@ -41,7 +55,7 @@ jobs: oc_token: ${{ secrets.OC_TOKEN }} file: libs/openshift.init.yml overwrite: false - parameters: -p ZONE=${{ github.event.number }} + parameters: -p ZONE=${{ env.ZONE }} triggers: ('db/' 'libs/' 'api/' 'admin/' 'public/') builds: @@ -49,6 +63,9 @@ jobs: runs-on: ubuntu-22.04 permissions: packages: write + needs: setup + env: + ZONE: ${{ needs.setup.outputs.zone }} strategy: matrix: package: [admin, api, db, public] @@ -75,15 +92,17 @@ jobs: build_context: ${{ matrix.build_context }} build_file: ${{ matrix.build_file }} keep_versions: 100 - tag: ${{ github.event.number }} + tag: ${{ env.ZONE }} tag_fallback: test token: ${{ secrets.GITHUB_TOKEN }} triggers: ${{ matrix.triggers }} deploys: name: Deploys - needs: [prep, builds] + needs: [prep, builds, setup] runs-on: ubuntu-22.04 + env: + ZONE: ${{ needs.setup.outputs.zone }} timeout-minutes: 10 strategy: matrix: @@ -123,7 +142,7 @@ jobs: overwrite: ${{ matrix.overwrite }} penetration_test: false parameters: - -p PROMOTE=ghcr.io/${{ github.repository }}/${{ matrix.name }}:${{ github.event.number }} - -p URL=fom-${{ github.event.number }}.apps.silver.devops.gov.bc.ca - -p ZONE=${{ github.event.number }} ${{ matrix.parameters }} + -p PROMOTE=ghcr.io/${{ github.repository }}/${{ matrix.name }}:${{ env.ZONE }} + -p URL=fom-${{ env.ZONE }}.apps.silver.devops.gov.bc.ca + -p ZONE=${{ env.ZONE }} ${{ matrix.parameters }} triggers: ${{ matrix.triggers }} diff --git a/api/src/app/app.module.ts b/api/src/app/app.module.ts index 4538160c5..cf020ad68 100644 --- a/api/src/app/app.module.ts +++ b/api/src/app/app.module.ts @@ -70,4 +70,4 @@ function getLogLevel():string { }) export class AppModule { constructor(private appConfigService: AppConfigService) {} -} +} \ No newline at end of file