Skip to content

Merge pull request #488 from bcgov/dev-marshal-NK-4411 #173

Merge pull request #488 from bcgov/dev-marshal-NK-4411

Merge pull request #488 from bcgov/dev-marshal-NK-4411 #173

Workflow file for this run

name: Web CD
on:
push:
branches:
- dev
- main
- dev-marshal
- test-marshal
paths:
- "web/**"
- ".github/workflows/web-cd.yml"
defaults:
run:
shell: bash
working-directory: ./web
env:
APP_NAME: "reviewer-web"
TOOLS_NAME: "${{secrets.OPENSHIFT4_REPOSITORY}}"
jobs:
web-cd-by-push:
runs-on: ubuntu-20.04
if: github.event_name == 'push' && github.repository == 'bcgov/foi-docreviewer'
steps:
- uses: actions/checkout@v2
- name: Set ENV variables for dev branch
if: ${{ github.ref_name == 'dev' }}
shell: bash
run: |
echo "For ${{ github.ref_name }} branch"
echo "TAG_NAME=dev" >> $GITHUB_ENV
echo "BRANCH_NAME=dev" >> $GITHUB_ENV
echo "ENV_NAME=dev" >> $GITHUB_ENV
- name: Set ENV variables for main branch
if: ${{ github.ref_name == 'main' }}
shell: bash
run: |
echo "For ${{ github.ref_name }} branch"
echo "TAG_NAME=test" >> $GITHUB_ENV
echo "BRANCH_NAME=main" >> $GITHUB_ENV
echo "ENV_NAME=test" >> $GITHUB_ENV
- name: Set ENV variables for dev-marshal branch
if: ${{ github.ref_name == 'dev-marshal' }}
run: |
echo "For ${{ github.ref_name }} branch"
echo "TAG_NAME=dev-marshal" >> $GITHUB_ENV
echo "BRANCH_NAME=dev-marshal" >> $GITHUB_ENV
echo "ENV_NAME=dev" >> $GITHUB_ENV
- name: Set ENV variables for test-marshal branch
if: ${{ github.ref_name == 'test-marshal' }}
run: |
echo "For ${{ github.ref_name }} branch"
echo "TAG_NAME=test-marshal" >> $GITHUB_ENV
echo "BRANCH_NAME=test-marshal" >> $GITHUB_ENV
echo "ENV_NAME=test" >> $GITHUB_ENV
- name: Login Openshift
shell: bash
run: |
oc login --server=${{secrets.OPENSHIFT4_LOGIN_REGISTRY}} --token=${{secrets.OPENSHIFT4_SA_TOKEN}}
- name: Tools project
shell: bash
run: |
oc project ${{ env.TOOLS_NAME }}-tools
- name: Build from ${{ env.BRANCH_NAME }} branch
shell: bash
run: |
oc patch bc/${{ env.APP_NAME }}-build -p '{"spec":{"source":{"contextDir":"/web","git":{"ref":"${{ env.BRANCH_NAME }}"}}}}'
- name: Start Build Openshift
shell: bash
run: |
oc start-build ${{ env.APP_NAME }}-build --wait
- name: Tag+Deploy for ${{ env.TAG_NAME }}
shell: bash
run: |
oc tag ${{ env.APP_NAME }}:latest ${{ env.APP_NAME }}:${{ env.TAG_NAME }}
- name: Watch new rollout (trigger by image change in Openshift)
shell: bash
run: |
oc rollout status dc/${{ env.APP_NAME }} -n ${{ env.TOOLS_NAME }}-${{ env.ENV_NAME }} -w