Skip to content

Merge pull request #103 from bcgov/test #12

Merge pull request #103 from bcgov/test

Merge pull request #103 from bcgov/test #12

---
name: Build and push Validator frontend application image
# Limit GITHUB_TOKEN permissions to only read repo contents.
permissions:
contents: read
on:
push:
paths:
- validator/frontend/**
branches: [dev, test, main]
workflow_dispatch:
# Cancel any currently running builds to save GitHub Actions hours.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
name: Validator frontend build and push
runs-on: ubuntu-latest
# Don't run on forks
if: github.repository == 'bcgov/standard-graphemes'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Determine environment tag
id: env-tag
run: |
echo "Evaluating branch: ${{ github.ref }}";
if [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "tag=dev" >> $GITHUB_ENV;
echo "VITE_API_BASE_URL=https://validator-backend-${{ secrets.OPENSHIFT_SILVER_LICENSE_PLATE}}-dev.apps.silver.devops.gov.bc.ca" >> $GITHUB_ENV;
elif [[ "${{ github.ref }}" == "refs/heads/test" ]]; then
echo "tag=test" >> $GITHUB_ENV;
echo "VITE_API_BASE_URL=https://validator-backend-${{ secrets.OPENSHIFT_SILVER_LICENSE_PLATE}}-test.apps.silver.devops.gov.bc.ca" >> $GITHUB_ENV;
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "tag=prod" >> $GITHUB_ENV;
echo "VITE_API_BASE_URL=https://validator-backend-${{ secrets.OPENSHIFT_SILVER_LICENSE_PLATE}}-prod.apps.silver.devops.gov.bc.ca" >> $GITHUB_ENV;
else
echo "Unknown branch: ${{ github.ref }}. Exiting...";
exit 1;
fi;
shell: bash
- name: Build image with docker build
run: docker build ./validator/frontend/ -f ./validator/frontend/Dockerfile -t validator-frontend:latest --build-arg VITE_API_BASE_URL=${{ env.VITE_API_BASE_URL }}
- name: Login to OpenShift Silver image registry
uses: docker/login-action@v3
with:
registry: image-registry.apps.silver.devops.gov.bc.ca
# This refers to the serviceaccount name alone, not the fully qualified
# value that comes out of `oc whoami` when logged in as the SA.
# Ex: For `system:serviceaccount:<name space>:<service account name>`,
# just use `<service account name>`.
username: ${{ secrets.OPENSHIFT_SILVER_SERVICEACCOUNT_USERNAME }}
password: ${{ secrets.OPENSHIFT_SILVER_SERVICEACCOUNT_TOKEN }}
- name: Tag and push Docker image
run: |
docker tag validator-frontend:latest image-registry.apps.silver.devops.gov.bc.ca/${{ secrets.OPENSHIFT_SILVER_LICENSE_PLATE }}-tools/validator-frontend:${{ env.tag }}
docker push image-registry.apps.silver.devops.gov.bc.ca/${{ secrets.OPENSHIFT_SILVER_LICENSE_PLATE }}-tools/validator-frontend --all-tags