Skip to content

Merge pull request #112 from bcgov/dev #100

Merge pull request #112 from bcgov/dev

Merge pull request #112 from bcgov/dev #100

Workflow file for this run

name: Create and publish Realm Registry App image
on:
push:
branches:
- main
- dev
paths:
- 'app/**'
- 'helm/**'
- '.github/workflows/publish-image.yml'
env:
GITHUB_REGISTRY: ghcr.io
IMAGE_NAME: bcgov/sso-realm-registry
jobs:
build-and-push-image:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: hmarr/debug-action@v2
- uses: actions/checkout@v2
- name: Log in to the GitHub Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: app
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Set env to development
if: (github.ref == 'refs/heads/dev' && github.event_name == 'push')
run: |
cat >> $GITHUB_ENV <<EOF
OPENSHIFT_TOKEN=${{ secrets.DEV_OPENSHIFT_TOKEN }}
OPENSHIFT_NAMESPACE=${{ secrets.DEV_OPENSHIFT_NAMESPACE }}
EOF
- name: Set env to production
if: (github.ref == 'refs/heads/main' && github.event_name == 'push')
run: |
cat >> $GITHUB_ENV <<EOF
OPENSHIFT_TOKEN=${{ secrets.PROD_OPENSHIFT_TOKEN }}
OPENSHIFT_NAMESPACE=${{ secrets.PROD_OPENSHIFT_NAMESPACE }}
EOF
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ env.OPENSHIFT_TOKEN }}
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
insecure_skip_tls_verify: true
- name: Deploy app with Helm chart
run: |
namespace=${{ env.OPENSHIFT_NAMESPACE }}
helm dep up
helm upgrade --install --atomic realm-registry . -n ${namespace} \
-f values.yaml -f "values-${namespace}.yaml"
working-directory: ./helm/webapp
- name: Create Release
if: github.ref == 'refs/heads/main'
id: release
uses: rymndhng/[email protected]
with:
bump_version_scheme: 'patch'
tag_prefix: 'v'
use_github_release_notes: 'true'
release_name: 'Release <RELEASE_VERSION>'
max_commits: 100 # default is 50