Skip to content

Merge pull request #60 from bcgov/fix/input-extraction #161

Merge pull request #60 from bcgov/fix/input-extraction

Merge pull request #60 from bcgov/fix/input-extraction #161

name: Build and Deploy
on:
push:
branches:
- main
- dev
- pipeline
workflow_dispatch: # Allows us to trigger this workflow from elsewhere (like the rules repo)
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract current branch name
id: extract_branch
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# This is the branch name we want to use of the rules repo branch
# We want it to be the same as the branch we are building so they stay in sync
build-args: |
RULES_REPO_BRANCH=${{ env.BRANCH_NAME }}
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
deploy:
needs: build_image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install OpenShift CLI
run: |
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz
tar -xvf oc.tar.gz
sudo mv oc /usr/local/bin
- name: Authenticate and set context for OpenShift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
namespace: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_NAMESPACE || secrets.OPENSHIFT_DEV_NAMESPACE }}
openshift_token: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_TOKEN || secrets.OPENSHIFT_DEV_TOKEN }}
insecure_skip_tls_verify: true
- name: Run Helm
run: |
helm upgrade --install brm-backend ./helm --set image.tag=${{ needs.build_image.outputs.image_tag }}