Skip to content

Commit

Permalink
Try deploy urls (#475)
Browse files Browse the repository at this point in the history
* test deploy urls within a range

* Revert "test deploy urls within a range"

This reverts commit 7acfdcb.

* test deploy urls within a range

* test urls

* fix typo

* test urls

* test urls

* add a comment to trigger deployment

* try custom number

* add a comment to trigger deployment

* test github action variable

* test

* test

* test

* test

* test

* change the numer

* fix: remove unused comment
  • Loading branch information
MCatherine1994 authored Nov 6, 2023
1 parent 56e8146 commit 39de058
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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 }}
37 changes: 28 additions & 9 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
Expand All @@ -41,14 +55,17 @@ 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:
name: Builds
runs-on: ubuntu-22.04
permissions:
packages: write
needs: setup
env:
ZONE: ${{ needs.setup.outputs.zone }}
strategy:
matrix:
package: [admin, api, db, public]
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ function getLogLevel():string {
})
export class AppModule {
constructor(private appConfigService: AppConfigService) {}
}
}

0 comments on commit 39de058

Please sign in to comment.