diff --git a/.github/workflows/.deploy.yml b/.github/workflows/.deploy.yml new file mode 100644 index 00000000..bb8c2159 --- /dev/null +++ b/.github/workflows/.deploy.yml @@ -0,0 +1,94 @@ +name: .Deploys + +on: + workflow_call: + inputs: + ### Required + # Nothing! Only `secrets: inherit` is required + + ### Typical / recommended + environment: + description: GitHub/OpenShift environment; usually PR number, test or prod + type: string + tag: + description: Container tag; usually PR number + default: ${{ github.event.number }} + type: string + target: + description: Deployment target; usually PR number, test or prod + default: ${{ github.event.number }} + type: string + triggers: + description: Paths to check for changes + type: string + url: + description: URL for deployment, does not include path + type: string + +permissions: {} + +jobs: + init: + name: Init + environment: ${{ inputs.environment }} + outputs: + url: ${{ steps.url.outputs.url }} + runs-on: ubuntu-24.04 + steps: + - name: Create URL + id: url + run: | + if [ -z "${{ inputs.url }}" ]; then + echo "Creating URL" + echo "url=fom-$(( ${{ inputs.target }} % 50 )).apps.silver.devops.gov.bc.ca" >> $GITHUB_OUTPUT + else + echo "Using URL parameter" + echo "url=${{ inputs.url }}" >> $GITHUB_OUTPUT + fi + + - name: OpenShift Init + uses: bcgov-nr/action-deployer-openshift@v3.0.1 + with: + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + file: libs/openshift.init.yml + overwrite: false + parameters: -p ZONE=${{ inputs.target }} + triggers: ${{ inputs.triggers }} + + deploy: + name: Deploy + needs: [init] + runs-on: ubuntu-24.04 + timeout-minutes: 10 + strategy: + matrix: + name: [api, admin, db, public] + include: + - name: api + overwrite: true + parameters: + -p FOM_EMAIL_NOTIFY=SIBIFSAF@victoria1.gov.bc.ca + -p DB_TESTDATA=true + -p AWS_USER_POOLS_WEB_CLIENT_ID="7hpo4qa7j0hs0rkfl2pm0sto5k" + -p LOGOUT_CHAIN_URL="https://logontest7.gov.bc.ca/clp-cgi/logoff.cgi?retnow=1&returl=https://dev.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/logout?redirect_uri=" + - name: admin + overwrite: true + - name: db + overwrite: false + - name: public + overwrite: true + steps: + - uses: bcgov-nr/action-deployer-openshift@v3.0.1 + with: + file: ${{ matrix.name }}/openshift.deploy.yml + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + overwrite: ${{ matrix.overwrite }} + parameters: + -p ZONE=${{ inputs.target }} -p TAG=${{ inputs.tag }} + -p URL=${{ needs.init.outputs.url }} -p REPLICA_COUNT=1 + ${{ matrix.parameters }} + triggers: ${{ inputs.triggers }} diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 1b09e8d5..a3e7b049 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -10,32 +10,8 @@ concurrency: permissions: {} jobs: - init: - name: Init - permissions: - pull-requests: write - runs-on: ubuntu-24.04 - outputs: - route_number: ${{ steps.calculate.outputs.route_number }} - steps: - - name: Calculate the deployment number - id: calculate - run: | - echo "route_number=$((${{ github.event.number }} % 50))" >> $GITHUB_OUTPUT - - - name: OpenShift Init - uses: bcgov-nr/action-deployer-openshift@v3.0.1 - with: - oc_namespace: ${{ vars.OC_NAMESPACE }} - oc_server: ${{ vars.OC_SERVER }} - oc_token: ${{ secrets.OC_TOKEN }} - file: libs/openshift.init.yml - overwrite: false - parameters: -p ZONE=${{ github.event.number }} - triggers: ('db/' 'libs/' 'api/' 'admin/' 'public/') - - builds: - name: Builds + build: + name: Build runs-on: ubuntu-24.04 permissions: packages: write @@ -70,53 +46,17 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} triggers: ${{ matrix.triggers }} - deploys: - name: Deploys - needs: [builds, init] - runs-on: ubuntu-24.04 - timeout-minutes: 10 - strategy: - matrix: - name: [api, admin, db, public] - include: - - name: api - file: api/openshift.deploy.yml - overwrite: true - parameters: - -p REPLICA_COUNT=1 - -p FOM_EMAIL_NOTIFY=SIBIFSAF@victoria1.gov.bc.ca - -p DB_TESTDATA=true - -p AWS_USER_POOLS_WEB_CLIENT_ID="7hpo4qa7j0hs0rkfl2pm0sto5k" - -p LOGOUT_CHAIN_URL="https://logontest7.gov.bc.ca/clp-cgi/logoff.cgi?retnow=1&returl=https://dev.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/logout?redirect_uri=" - - name: admin - file: admin/openshift.deploy.yml - overwrite: true - parameters: -p REPLICA_COUNT=1 - - name: db - file: db/openshift.deploy.yml - overwrite: false - - name: public - file: public/openshift.deploy.yml - overwrite: true - parameters: -p REPLICA_COUNT=1 - steps: - - uses: bcgov-nr/action-deployer-openshift@v3.0.1 - with: - file: ${{ matrix.file }} - oc_namespace: ${{ vars.OC_NAMESPACE }} - oc_server: ${{ vars.OC_SERVER }} - oc_token: ${{ secrets.OC_TOKEN }} - overwrite: ${{ matrix.overwrite }} - penetration_test: false - parameters: - -p URL=fom-${{ needs.init.outputs.route_number }}.apps.silver.devops.gov.bc.ca - -p ZONE=${{ github.event.number }} -p TAG=${{ github.event.number }} - ${{ matrix.parameters }} - triggers: ('db/' 'libs/' 'api/' 'admin/' 'public/') + deploy: + name: Deploy (${{ github.event.number }}) + needs: [build] + secrets: inherit + uses: ./.github/workflows/.deploy.yml + with: + triggers: ('db/' 'libs/' 'api/' 'admin/' 'public/') results: name: PR Results - needs: [builds, deploys] + needs: [build, deploy] if: always() runs-on: ubuntu-24.04 steps: diff --git a/db/openshift.deploy.yml b/db/openshift.deploy.yml index c00a3953..4dcd8e64 100644 --- a/db/openshift.deploy.yml +++ b/db/openshift.deploy.yml @@ -46,6 +46,8 @@ parameters: value: 1Gi - name: URL description: Dummy parameter to make workflows easier + - name: REPLICA_COUNT + description: Dummy parameter to make workflows easier ### Backup-Container starts here ### - name: BACKUP_COMPONENT description: BACKUP_COMPONENT name