Skip to content

Feature/descw chart release workflow #7

Feature/descw chart release workflow

Feature/descw chart release workflow #7

name: buildTestPublishContainerDeploy
on:
push:
branches:
- main
release:
types:
- published
pull_request:
workflow_dispatch:
env:
notifyBCContainerTag: latest
jobs:
install-build-lint-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v2.3.1
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Install, build, lint and test:e2e πŸ”§
run: |
yarn install
yarn build
yarn lint
yarn test:e2e
publish-container:
if: ${{ github.repository == 'bcgov/NotifyBC' && github.event_name != 'pull_request' }}
needs: install-build-lint-and-test
runs-on: ubuntu-latest
steps:
- name: Update notifyBCContainerTag for tags
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: echo notifyBCContainerTag=$(echo $GITHUB_REF | cut -d / -f 3 | cut -d v -f 2- | cut -d . -f 1,2) >> $GITHUB_ENV
- name: Update notifyBCContainerTag for branches
if: ${{ startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/main' }}
run: echo notifyBCContainerTag=$(echo $GITHUB_REF | cut -d / -f 3) >> $GITHUB_ENV
- name: Save $notifyBCContainerTag to file
run: |
echo $notifyBCContainerTag > notifyBCContainerTag.txt
- name: Upload notifyBCContainerTag
if: ${{ startsWith(github.ref, 'refs/heads/') }}
uses: actions/upload-artifact@v2
with:
name: notifyBCContainerTag
path: notifyBCContainerTag.txt
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v2.3.1
with:
persist-credentials: false
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Publish Container πŸš€
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/bcgov/notify-bc:${{ env.notifyBCContainerTag }}
build-args: nodeVersion=${{ vars.NODE_VERSION }}
deploy:
if: ${{ github.repository == 'bcgov/NotifyBC' && github.event_name == 'push' }}
needs: publish-container
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v2.3.1
with:
persist-credentials: false
- name: Decrypt values.ocp4.dev.yaml.gpg
run: ./.github/scripts/decrypt_secret.sh
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Install oc
uses: redhat-actions/oc-installer@v1
- name: Authenticate to OCP4 and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL }}
openshift_token: ${{ secrets.OPENSHIFT_API_TOKEN }}
namespace: ${{ secrets.OPENSHIFT_PROJECT }}-dev
- name: Download notifyBCContainerTag
uses: actions/download-artifact@v2
with:
name: notifyBCContainerTag
- name: helm upgrade πŸš€
run: |
export notifyBCContainerTag=`cat notifyBCContainerTag.txt`
helm upgrade -f helm/platform-specific/openshift.yaml \
-f .github/values.ocp4.dev.yaml --set \
image.tag="$notifyBCContainerTag" `helm ls -q` helm
oc get deployment -o name | xargs oc rollout restart