forked from bcgov/NotifyBC
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (91 loc) · 3.05 KB
/
buildTestPublishContainerDeploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: buildTestPublishContainerDeploy
on:
push:
branches:
- main
release:
types:
- published
pull_request:
workflow_dispatch:
env:
notifyBCContainerTag: latest
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4.1.4
with:
persist-credentials: false
- uses: actions/setup-node@v4.0.2
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Install and Test 🔧
run: |
npm ci
yarn test
- name: Set package version
run: echo "notifyBCContainerTag=$(npm pkg get version)" >> $GITHUB_ENV
publish-container:
if: ${{ github.repository == 'bcgov/des-notifybc' && github.event_name != 'pull_request' }}
needs: build-and-test
runs-on: ubuntu-latest
steps:
- 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@v4.1.4
with:
persist-credentials: false
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Container 🚀
uses: docker/build-push-action@v5.3.0
with:
push: true
tags: ghcr.io/bcgov/des-notify-bc:${{ env.notifyBCContainerTag }}
build-args: nodeVersion=${{ vars.NODE_VERSION }}
deploy:
if: ${{ github.repository == 'bcgov/des-notifybc' && github.event_name == 'push' }}
needs: publish-container
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4.1.4
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