Skip to content

Merge pull request #5488 from bcgov/test-marshal-NC-3197 #1149

Merge pull request #5488 from bcgov/test-marshal-NC-3197

Merge pull request #5488 from bcgov/test-marshal-NC-3197 #1149

name: Forms-Flow-Web CD
on:
push:
branches:
- dev
- dev-marshal
- test-marshal
- dev-rook
- test-rook
- main
paths:
- "forms-flow-web/**"
defaults:
run:
shell: bash
working-directory: ./forms-flow-web
env:
APP_NAME: "forms-flow-web"
jobs:
forms-flow-web-cd-by-push:
runs-on: ubuntu-20.04
if: github.event_name == 'push' && github.repository == 'bcgov/foi-flow'
steps:
- uses: actions/checkout@v2
- name: Set ENV variables
id: set-variable
run: |
if [ ${{ github.ref_name }} == 'dev' ]; then
echo "For ${{ github.ref_name }} branch"
echo "TOOLS_NAME=${{secrets.OPENSHIFT4_FRONTEND_REPOSITORY}}" >> $GITHUB_ENV
echo "TAG_NAME="dev"" >> $GITHUB_ENV
echo "BRANCH_NAME="dev"" >> $GITHUB_ENV
echo "ENV_NAME="dev"" >> $GITHUB_ENV
elif [ ${{ github.ref_name }} == 'dev-marshal' ]; then
echo "For ${{ github.ref_name }} branch"
echo "TOOLS_NAME=${{secrets.OPENSHIFT4_FRONTEND_REPOSITORY}}" >> $GITHUB_ENV
echo "TAG_NAME="dev-marshal"" >> $GITHUB_ENV
echo "BRANCH_NAME="dev-marshal"" >> $GITHUB_ENV
echo "ENV_NAME="dev"" >> $GITHUB_ENV
elif [ ${{ github.ref_name }} == 'test-marshal' ]; then
echo "For ${{ github.ref_name }} branch"
echo "TOOLS_NAME=${{secrets.OPENSHIFT4_FRONTEND_REPOSITORY}}" >> $GITHUB_ENV
echo "TAG_NAME="test-marshal"" >> $GITHUB_ENV
echo "BRANCH_NAME="test-marshal"" >> $GITHUB_ENV
echo "ENV_NAME="test"" >> $GITHUB_ENV
elif [ ${{ github.ref_name }} == 'dev-rook' ]; then
echo "For ${{ github.ref_name }} branch"
echo "TOOLS_NAME=${{secrets.OPENSHIFT4_FRONTEND_REPOSITORY}}" >> $GITHUB_ENV
echo "TAG_NAME="dev-rook"" >> $GITHUB_ENV
echo "BRANCH_NAME="dev-rook"" >> $GITHUB_ENV
echo "ENV_NAME="dev"" >> $GITHUB_ENV
elif [ ${{ github.ref_name }} == 'test-rook' ]; then
echo "For ${{ github.ref_name }} branch"
echo "TOOLS_NAME=${{secrets.OPENSHIFT4_FRONTEND_REPOSITORY}}" >> $GITHUB_ENV
echo "TAG_NAME="test-rook"" >> $GITHUB_ENV
echo "BRANCH_NAME="test-rook"" >> $GITHUB_ENV
echo "ENV_NAME="test"" >> $GITHUB_ENV
elif [ ${{ github.ref_name }} == 'main' ]; then
echo "For ${{ github.ref_name }} branch"
echo "TOOLS_NAME=${{secrets.OPENSHIFT4_FRONTEND_REPOSITORY}}" >> $GITHUB_ENV
echo "TAG_NAME="test"" >> $GITHUB_ENV
echo "BRANCH_NAME="main"" >> $GITHUB_ENV
echo "ENV_NAME="test"" >> $GITHUB_ENV
else
echo "For ${{ github.ref_name }} branch"
fi
shell: bash
- 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 }} -p '{"spec":{"source":{"contextDir":"/forms-flow-web","git":{"ref":"${{ env.BRANCH_NAME }}"}}}}'
- name: Start Build Openshift
shell: bash
run: |
oc start-build ${{ env.APP_NAME }} --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