Skip to content

Added env check (#68) #32

Added env check (#68)

Added env check (#68) #32

Workflow file for this run

# Build and Deploy to dev env.
# Trigger with tag dev
# Connected with repo environment 'dev'
name: OpenShift Build and Deploy to api and web
on:
push:
branches:
- main-dev
env:
CLUSTER: https://api.silver.devops.gov.bc.ca:6443
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN_OCP4 }}
BUILD_REF: ${{ github.base_ref }}
ENV_PREFIX: dev
NAMESPACE_DEV: ${{ vars.NAMESPACE_DEV }}
SOAM_CLIENT_ID_DEV: ${{ vars.SOAM_CLIENT_ID_DEV }}
SOAM_CLIENT_SECRET_DEV: ${{ secrets.SOAM_CLIENT_SECRET_DEV }}
PUBLIC_HOST: dev.independentschoolservices.gov.bc.ca
jobs:
# Api build
api-build:
name: OpenShift Build & Deploy
runs-on: ubuntu-latest
concurrency: ci-build-api
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check changes on backend code
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'backend/**'
base: ${{ github.ref}}
- name: Build changes
if: steps.changes.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make build-api
make promote-api
# Web build
web-build:
name: OpenShift Build & Deploy
runs-on: ubuntu-latest
concurrency: ci-build-web
timeout-minutes: 20
environment:
name: dev
env:
CERTIFICATE: ${{ secrets.CERT }}
CA_CERT: ${{ secrets.CA_CERT }}
PRIVATE_KEY: ${{ secrets.PRIV_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'frontend/**'
base: ${{ github.ref }}
- name: Build changes
if: steps.changes.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make build-web
make promote-web
app-promote:
name: Prmoting application
runs-on: ubuntu-latest
timeout-minutes: 20
needs:
- api-build
- web-build
environment:
name: dev
env:
CERTIFICATE: ${{ secrets.CERT }}
CA_CERT: ${{ secrets.CA_CERT }}
PRIVATE_KEY: ${{ secrets.PRIV_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check changes on dir
uses: dorny/paths-filter@v2
id: changes_tools
with:
filters: |
src:
- 'backend/**'
- 'tools/**'
base: ${{ github.ref}}
- name: Deploy changes api
if: steps.changes_tools.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make deploy-api
- name: Check changes on dir
uses: dorny/paths-filter@v2
id: changes_tools_web
with:
filters: |
src:
- 'frontend/**'
- 'tools/**'
base: ${{ github.ref }}
- name: Deploy changes of web
if: steps.changes_tools_web.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make promote-web
make deploy-web
- name: Create Route
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
echo Creating route with ${{ env.PUBLIC_HOST }}
oc --namespace=${{ env.NAMESPACE_DEV }} process -f openshift/public-route.yml \
-p NAME=web-ecc-iosas \
-p PUBLIC_HOST=${{ env.PUBLIC_HOST }} \
-p CERTIFICATE="${{ secrets.CERT }}" \
-p CA_CERT="${{ secrets.CA_CERT }}" \
-p PRIVATE_KEY="${{ secrets.PRIV_KEY }}" | oc --namespace=${{ env.NAMESPACE_DEV }} apply -f -