18486 - Pinia Setup (#195) #303
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: FAS Web CD | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "Environment (dev/test/prod)" | |
required: true | |
default: "dev" | |
defaults: | |
run: | |
shell: bash | |
env: | |
APP_NAME: "fas-ui" | |
TAG_NAME: "dev" | |
jobs: | |
fas-ui-cd-by-push: | |
runs-on: ubuntu-20.04 | |
if: github.event_name == 'push' && github.repository == 'bcgov/fas-ui' | |
environment: | |
name: "dev" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Login Openshift | |
shell: bash | |
run: | | |
oc login --server=${{secrets.OPENSHIFT4_LOGIN_REGISTRY}} --token=${{secrets.OPENSHIFT4_SA_TOKEN}} | |
# Get environment variables from 1password | |
- name: Setup .env file | |
env: | |
OP_CONNECT_HOST: ${{ secrets.OP_CONNECT_URL }} | |
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }} | |
APP_ENV: ${{ env.TAG_NAME }} | |
run: | | |
curl -sSfo op.zip \ | |
https://cache.agilebits.com/dist/1P/op2/pkg/v2.0.0/op_linux_amd64_v2.0.0.zip \ | |
&& unzip -od /usr/local/bin/ op.zip \ | |
&& rm op.zip ;\ | |
op inject -i ./devops/vaults.env -o .env -f | |
- name: CD Flow | |
shell: bash | |
env: | |
OPS_REPOSITORY: ${{ secrets.OPS_REPOSITORY }} | |
OPENSHIFT_DOCKER_REGISTRY: ${{ secrets.OPENSHIFT4_DOCKER_REGISTRY }} | |
OPENSHIFT_SA_NAME: ${{ secrets.OPENSHIFT4_SA_NAME }} | |
OPENSHIFT_SA_TOKEN: ${{ secrets.OPENSHIFT4_SA_TOKEN }} | |
OPENSHIFT_REPOSITORY: ${{ secrets.OPENSHIFT4_REPOSITORY }} | |
TAG_NAME: ${{ env.TAG_NAME }} | |
run: | | |
make cd | |
- name: Watch new rollout (trigger by image change in Openshift) | |
shell: bash | |
run: | | |
oc rollout status dc/${{ env.APP_NAME }}-${{ env.TAG_NAME }} -n ${{ secrets.OPENSHIFT4_REPOSITORY }}-${{ env.TAG_NAME }} -w | |
- name: Rocket.Chat Notification | |
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master | |
if: failure() | |
with: | |
type: ${{ job.status }} | |
job_name: "*FAS UI Built and Deployed to ${{env.TAG_NAME}}*" | |
channel: "#registries-bot" | |
url: ${{ secrets.ROCKETCHAT_WEBHOOK }} | |
commit: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fas-ui-cd-by-dispatch: | |
runs-on: ubuntu-20.04 | |
if: github.event_name == 'workflow_dispatch' && github.repository == 'bcgov/fas-ui' | |
environment: | |
name: "${{ github.event.inputs.environment }}" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set env by input | |
run: | | |
echo "TAG_NAME=${{ github.event.inputs.environment }}" >> $GITHUB_ENV | |
- name: Login Openshift | |
shell: bash | |
run: | | |
oc login --server=${{secrets.OPENSHIFT4_LOGIN_REGISTRY}} --token=${{secrets.OPENSHIFT4_SA_TOKEN}} | |
# Get environment variables from 1password | |
- name: Setup .env file | |
env: | |
OP_CONNECT_HOST: ${{ secrets.OP_CONNECT_URL }} | |
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }} | |
APP_ENV: ${{ env.TAG_NAME }} | |
run: | | |
curl -sSfo op.zip \ | |
https://cache.agilebits.com/dist/1P/op2/pkg/v2.0.0/op_linux_amd64_v2.0.0.zip \ | |
&& unzip -od /usr/local/bin/ op.zip \ | |
&& rm op.zip ;\ | |
op inject -i ./devops/vaults.env -o .env -f | |
- name: CD Flow | |
shell: bash | |
env: | |
OPS_REPOSITORY: ${{ secrets.OPS_REPOSITORY }} | |
OPENSHIFT_DOCKER_REGISTRY: ${{ secrets.OPENSHIFT4_DOCKER_REGISTRY }} | |
OPENSHIFT_SA_NAME: ${{ secrets.OPENSHIFT4_SA_NAME }} | |
OPENSHIFT_SA_TOKEN: ${{ secrets.OPENSHIFT4_SA_TOKEN }} | |
OPENSHIFT_REPOSITORY: ${{ secrets.OPENSHIFT4_REPOSITORY }} | |
TAG_NAME: ${{ env.TAG_NAME }} | |
run: | | |
make cd | |
- name: Watch new rollout (trigger by image change in Openshift) | |
shell: bash | |
run: | | |
oc rollout status dc/${{ env.APP_NAME }}-${{ env.TAG_NAME }} -n ${{ secrets.OPENSHIFT4_REPOSITORY }}-${{ env.TAG_NAME }} -w | |
- name: Rocket.Chat Notification | |
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master | |
if: failure() | |
with: | |
type: ${{ job.status }} | |
job_name: "*FAS-UI Built and Deployed to ${{env.TAG_NAME}}*" | |
channel: "#registries-bot" | |
url: ${{ secrets.ROCKETCHAT_WEBHOOK }} | |
commit: true | |
token: ${{ secrets.GITHUB_TOKEN }} |