forked from bcgov/PSP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add uat hotfix and pre-release hotfix pipelines. update builds/keycloak sync to support new configuration.
- Loading branch information
1 parent
bba7bd8
commit 776cbbd
Showing
13 changed files
with
636 additions
and
37 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Keycloak Sync | ||
env: | ||
OPENSHIFT_TOOLS_NAMESPACE: "3cd915-tools" | ||
MS_TEAMS_WEBHOOK_BUILD_CHANNEL: ${{ secrets.MS_TEAMS_WEBHOOK_URI_BUILD_CHANNEL }} | ||
AUTH__KEYCLOAK__SECRET: ${{ secrets.KEYCLOAK_SECRET }} | ||
AUTH__KEYCLOAK__SERVICEACCOUNT__SECRET: ${{ secrets.KEYCLOAK_SERVICEACCOUNT_SECRET }} | ||
sync-directory: ./tools/keycloak/sync | ||
ASPNETCORE_ENVIRONMENT: "Development" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
sync-keycloak: | ||
name: Sync Keycloak | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup .NET 8 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: "8.0.x" | ||
|
||
- name: Install dependencies for keycloak sync | ||
run: dotnet restore | ||
working-directory: ${{env.sync-directory}} | ||
|
||
- name: Build keycloak sync | ||
run: dotnet build | ||
working-directory: ${{env.sync-directory}} | ||
|
||
- name: Start keycloak sync | ||
run: dotnet run | ||
working-directory: ${{env.sync-directory}} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
name: UAT Hotfix | ||
env: | ||
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }} | ||
# service account: gitaction | ||
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} | ||
OPENSHIFT_TOOLS_NAMESPACE: "3cd915-tools" | ||
MS_TEAMS_WEBHOOK_BUILD_CHANNEL: ${{ secrets.MS_TEAMS_WEBHOOK_URI_BUILD_CHANNEL }} | ||
AUTH__KEYCLOAK__SECRET: ${{ secrets.KEYCLOAK_SECRET }} | ||
AUTH__KEYCLOAK__SERVICEACCOUNT__SECRET: ${{ secrets.KEYCLOAK_SERVICEACCOUNT_SECRET }} | ||
sync-directory: ./tools/keycloak/sync | ||
ASPNETCORE_ENVIRONMENT: "uat" | ||
|
||
## variables for scripts under git\openshift\4.0\scripts\oc-*.sh | ||
APP_PORT: 8080 | ||
DESTINATION: "uat" | ||
OC_JOB_NAME: "test" | ||
GIT_URL: "${{github.server_url}}/${{github.repository}}" | ||
GIT_BRANCH: "test" | ||
APP_NAME: "pims" | ||
PROJ_PREFIX: "3cd915" | ||
PROJ_TOOLS: "3cd915-tools" | ||
PROJ_DEV: "dev" | ||
PROJ_TEST: "test" | ||
PROJ_PROD: "prod" | ||
TAG_DEV: "dev" | ||
TAG_TEST: "test" | ||
TAG_PROD: "prod" | ||
INSTANCE: "-uat" | ||
NAMESPACE_OVERRIDE: "3cd915-test" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci-cd-start-notification: | ||
name: CI-CD Start Notification to Teams Channel | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Start notification to Teams Channel | ||
uses: dragos-cojocari/[email protected] | ||
with: | ||
github-token: ${{ github.token }} | ||
ms-teams-webhook-uri: ${{ env.MS_TEAMS_WEBHOOK_BUILD_CHANNEL }} | ||
notification-summary: PIMS UAT Hotfix started. | ||
notification-color: 17a2b8 | ||
timezone: America/Los_Angeles | ||
|
||
build-frontend: | ||
name: Build frontend | ||
needs: ci-cd-start-notification | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
- name: Login to OpenShift | ||
uses: redhat-actions/oc-login@v1 | ||
with: | ||
openshift_server_url: ${{ env.OPENSHIFT_SERVER }} | ||
openshift_token: ${{ env.OPENSHIFT_TOKEN }} | ||
insecure_skip_tls_verify: true | ||
namespace: ${{ env.OPENSHIFT_TOOLS_NAMESPACE }} | ||
- name: Call script to build frontend (pims-app and pims-app-base) | ||
run: | | ||
./openshift/4.0/player.sh build app-base -apply | ||
./openshift/4.0/player.sh build app -apply | ||
build-api: | ||
name: Build api | ||
needs: ci-cd-start-notification | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
- name: Login to OpenShift | ||
uses: redhat-actions/oc-login@v1 | ||
with: | ||
openshift_server_url: ${{ env.OPENSHIFT_SERVER }} | ||
openshift_token: ${{ env.OPENSHIFT_TOKEN }} | ||
insecure_skip_tls_verify: true | ||
namespace: ${{ env.OPENSHIFT_TOOLS_NAMESPACE }} | ||
- name: Call script to build backend (pims-api) | ||
run: | | ||
./openshift/4.0/player.sh build api -apply | ||
deploy: | ||
name: Deploy frontend and api to OpenShift | ||
needs: [build-frontend, build-api] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
- name: Login to OpenShift | ||
uses: redhat-actions/oc-login@v1 | ||
with: | ||
openshift_server_url: ${{ env.OPENSHIFT_SERVER }} | ||
openshift_token: ${{ env.OPENSHIFT_TOKEN }} | ||
insecure_skip_tls_verify: true | ||
namespace: ${{ env.OPENSHIFT_TOOLS_NAMESPACE }} | ||
- name: call scripts to deploy api and frontend | ||
run: | | ||
./openshift/4.0/player.sh deploy api $DESTINATION -apply | ||
./openshift/4.0/player.sh deploy app $DESTINATION -apply | ||
# the command: | ||
# 1) creates an openshift job with generated name to avoid name conflict, substituting the variables in the template. | ||
# 2) greps the generated name from the previous step. | ||
# 3) waits for the job to complete using the generated name. | ||
database-upgrade: | ||
name: Upgrade database | ||
needs: [deploy] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
- name: Login to OpenShift | ||
uses: redhat-actions/oc-login@v1 | ||
with: | ||
openshift_server_url: ${{ env.OPENSHIFT_SERVER }} | ||
openshift_token: ${{ env.OPENSHIFT_TOKEN }} | ||
insecure_skip_tls_verify: true | ||
namespace: 3cd915-test | ||
- name: call scripts to upgrade database | ||
shell: bash | ||
run: | | ||
oc process -f ./openshift/4.0/templates/jobs/db-deploy.yaml -p DB_SECRET_NAME=pims-database-uat -p GIT_BRANCH=test -p SERVER_NAME=sqlprd.th.gov.bc.ca -p DB_NAME=PIMS_UAT -p NAMESPACE=3cd915-test | oc create -f - | grep -oP "(?<=job\.batch/)[^\s]*" | (read JOB_NAME; oc wait --for=condition=complete job/$JOB_NAME --timeout=120s) | ||
## Call the mayan sync task three times, once for each mayan sync endpoint. The task will wait for the job to complete before exiting. | ||
## Note: this depends on the mayan-sync configmap for the target namespace being up to date. | ||
mayan-sync: | ||
name: sync mayan | ||
needs: database-upgrade | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
- name: Login to OpenShift | ||
uses: redhat-actions/oc-login@v1 | ||
with: | ||
openshift_server_url: ${{ env.OPENSHIFT_SERVER }} | ||
openshift_token: ${{ env.OPENSHIFT_TOKEN }} | ||
insecure_skip_tls_verify: true | ||
namespace: 3cd915-test | ||
- name: call scripts to sync mayan | ||
shell: bash | ||
run: | | ||
oc process -f ./openshift/4.0/templates/jobs/mayan-sync.yaml -p NAMESPACE=3cd915-test -p TOKEN_URL=https://test.loginproxy.gov.bc.ca:443/auth/realms/standard/protocol/openid-connect/token -p CLIENT_ID=property-services-project-api-4380 -p MAYAN_SYNC_URL=https://https://uat-pims.th.gov.bc.ca/:443/api/documents/sync/mayan/metadatatype -p KEYCLOAK_SECRET_NAME=pims-api-sso-uat | oc create -f - | grep -oP "(?<=\/)[^\s]*" | (read TASK_NAME; oc wait --for=condition=succeeded taskruns/$TASK_NAME --timeout=80s) | ||
oc process -f ./openshift/4.0/templates/jobs/mayan-sync.yaml -p NAMESPACE=3cd915-test -p TOKEN_URL=https://test.loginproxy.gov.bc.ca:443/auth/realms/standard/protocol/openid-connect/token -p CLIENT_ID=property-services-project-api-4380 -p MAYAN_SYNC_URL=https://https://uat-pims.th.gov.bc.ca/:443/api/documents/sync/documenttype -p KEYCLOAK_SECRET_NAME=pims-api-sso-uat | oc create -f - | grep -oP "(?<=\/)[^\s]*" | (read TASK_NAME; oc wait --for=condition=succeeded taskruns/$TASK_NAME --timeout=80s) | ||
oc process -f ./openshift/4.0/templates/jobs/mayan-sync.yaml -p NAMESPACE=3cd915-test -p TOKEN_URL=https://test.loginproxy.gov.bc.ca:443/auth/realms/standard/protocol/openid-connect/token -p CLIENT_ID=property-services-project-api-4380 -p MAYAN_SYNC_URL=https://https://uat-pims.th.gov.bc.ca/:443/api/documents/sync/mayan -p KEYCLOAK_SECRET_NAME=pims-api-sso-uat | oc create -f - | grep -oP "(?<=\/)[^\s]*" | (read TASK_NAME; oc wait --for=condition=succeeded taskruns/$TASK_NAME --timeout=80s) | ||
sync-keycloak: | ||
name: Sync Keycloak | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup .NET 8 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: "8.0.x" | ||
|
||
- name: Install dependencies for keycloak sync | ||
run: dotnet restore | ||
working-directory: ${{env.sync-directory}} | ||
|
||
- name: Build keycloak sync | ||
run: dotnet build | ||
working-directory: ${{env.sync-directory}} | ||
|
||
- name: Start keycloak sync | ||
run: dotnet run | ||
working-directory: ${{env.sync-directory}} | ||
|
||
ci-cd-end-notification: | ||
if: always() | ||
name: CI-CD End Notification to Teams Channel | ||
runs-on: ubuntu-latest | ||
needs: [mayan-sync, sync-keycloak] | ||
steps: | ||
- name: check workflow status | ||
uses: martialonline/workflow-status@v4 | ||
id: check | ||
- name: End notification to Teams Channel | ||
uses: dragos-cojocari/[email protected] | ||
with: | ||
github-token: ${{ github.token }} | ||
ms-teams-webhook-uri: ${{ env.MS_TEAMS_WEBHOOK_BUILD_CHANNEL }} | ||
notification-summary: PIMS UAT Hotfix complete with status ${{ steps.check.outputs.status }} | ||
notification-color: 17a2b8 | ||
timezone: America/Los_Angeles |
Oops, something went wrong.