Merge branch 'test' #156
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: Build Main | |
# Build all of the necessary components for the PRIME application from `master` branch. Images are then deployed to Production environment via the prime-app-template.yml in the infrastructure folder | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
branches: | |
- master | |
jobs: | |
build-document-manager-backend: | |
runs-on: ubuntu-20.04 | |
environment: Production | |
steps: | |
- name: "Checkout the repo" | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.docman-cache | |
key: prime-docman-${{ github.sha }} | |
restore-keys: | | |
prime-docman- | |
- name: "Login to OpenShift repository" | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}} | |
username: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_USERNAME}} | |
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}} | |
- name: "Build Document Manager image" | |
run: | | |
docker build document-manager/backend/ \ | |
--file document-manager/backend/openshift.dockerfile \ | |
--tag prime-document-manager \ | |
--build-arg BUILD_LOGLEVEL=2 \ | |
--build-arg SVC_NAME=prod | |
- name: "Docker tag and push Document Manager image" | |
run: | | |
docker tag prime-document-manager ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-document-manager:prod | |
docker push ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-document-manager:prod | |
build-backend: | |
runs-on: ubuntu-20.04 | |
environment: Production | |
steps: | |
- name: "Checkout the repo" | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.backend-cache | |
key: prime-backend-${{ github.sha }} | |
restore-keys: | | |
prime-backend- | |
- name: "Login to OpenShift repository" | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}} | |
username: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_USERNAME}} | |
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}} | |
- name: "Login to RedHat container repository" | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{secrets.REDHAT_REGISTRY_URL}} | |
username: ${{secrets.REDHAT_REGISTRY_SERVICE_ACCOUNT_USER}} | |
password: ${{secrets.REDHAT_REGISTRY_SERVICE_ACCOUNT_AUTH_TOKEN}} | |
- name: "Build .NET web API image" | |
run: | | |
docker build prime-dotnet-webapi/ \ | |
--file prime-dotnet-webapi/openshift.dockerfile \ | |
--tag prime-webapi-backend \ | |
--build-arg ASPNETCORE_ENVIRONMENT="Development" \ | |
--build-arg ASPNETCORE_HTTPS_PORT=5001 \ | |
--build-arg ASPNETCORE_URLS="http://+:8080" \ | |
--build-arg DB_CONNECTION_STRING="host=postgres;port=5432;database=prime;username=$PRIME_DB_USER;password=$PRIME_DB_PASSWORD" \ | |
--build-arg DB_HOST=postgres \ | |
--build-arg DOTNET_CLI_HOME="/tmp/DOTNET_CLI_HOME" \ | |
--build-arg PGPASSWORD=${{secrets.PRIME_DB_PASSWORD}} \ | |
--build-arg POSTGRESQL_ADMIN_PASSWORD=${{secrets.PRIME_DB_PASSWORD}} \ | |
--build-arg POSTGRESQL_DATABASE=${{secrets.PRIME_DB_USER}}-${{steps.PR.outputs.number}} \ | |
--build-arg POSTGRESQL_USERNAME=${{secrets.PRIME_DB_USER}} \ | |
--build-arg SVC_NAME="prod" | |
- name: "Docker tag and push .NET web API image" | |
run: | | |
docker tag prime-webapi-backend ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-webapi-backend:prod | |
docker push ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-webapi-backend:prod | |
build-frontend: | |
runs-on: ubuntu-20.04 | |
environment: Production | |
defaults: | |
run: | |
working-directory: prime-angular-frontend | |
steps: | |
- name: "Checkout the repo" | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16.14.0' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.frontend-cache | |
key: prime-frontend-${{ github.sha }} | |
restore-keys: | | |
prime-frontend- | |
- name: "Login to OpenShift repository" | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}} | |
username: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_USERNAME}} | |
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}} | |
- name: install yarn | |
run: npm install -g yarn | |
- run: yarn global add @angular/compiler-cli@16.2.12 | |
- run: yarn global add @angular/cli@16.2.9 | |
- name: install dependencies | |
run: yarn | |
- name: build frontend | |
run: yarn run build | |
- name: "Build Angular frontend image" | |
run: | | |
docker build . \ | |
--file ci.dockerfile \ | |
--tag prime-angular-frontend | |
- name: "Docker tag and push Angular frontend image" | |
run: | | |
docker tag prime-angular-frontend ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-frontend:prod | |
docker push ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-frontend:prod | |
apply-oc-template: | |
runs-on: ubuntu-20.04 | |
environment: Production | |
needs: [build-document-manager-backend,build-frontend,build-backend] | |
steps: | |
- name: "Use the OpenShift template" | |
uses: actions/checkout@v3 | |
- name: Install OC | |
uses: redhat-actions/openshift-tools-installer@v1 | |
with: | |
oc: "4.6" | |
- name: Authenticate and set context | |
uses: redhat-actions/oc-login@v1.1 | |
with: | |
openshift_server_url: ${{secrets.OPENSHIFT_SERVER_URL}} | |
openshift_token: ${{secrets.OPENSHIFT_SERVICE_TOKEN}} | |
namespace: ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} | |
- name: "Process template" | |
id: oc | |
run: | | |
oc process -f infrastructure/prime-app-template.yml \ | |
-p ASP_ENV=Production \ | |
-p VANITY_URL=pharmanetenrolment.gov.bc.ca \ | |
-p IMAGE_TAG=prod \ | |
-p SVC_NAME=prod \ | |
-p OC_LICENSE_PLATE=${{secrets.OPENSHIFT_LICENSE_PLATE}} \ | |
-p OC_ENV=${{secrets.OPENSHIFT_ENVIRONMENT}} \ | |
-p URL_STUB=-${{secrets.OPENSHIFT_LICENSE_PLATE}}-prod.apps.silver.devops.gov.bc.ca \ | |
-p WEB_PORT=8080 \ | |
-p HPR_URL=healthpractitionerregistration.apps.silver.devops.gov.bc.ca \ | |
-p MAUTH_URL=prod-mauth-${{secrets.OPENSHIFT_LICENSE_PLATE}}-prod.apps.silver.devops.gov.bc.ca \ | |
-n ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} | oc apply -n ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} -f - |