-
Notifications
You must be signed in to change notification settings - Fork 11
77 lines (64 loc) · 2.68 KB
/
build-deploy-backup-dev.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
name: Build & Deploy Backup - Develop
on:
pull_request: # remove after pr is approved / before pr is merged
workflow_dispatch:
push:
branches:
- develop
paths:
- prime-database-backup/**
- .github/workflows/build-deploy-backup-dev.yml
env:
NAME: backup
INITIAL_TAG: latest
TAG: dev
CONTEXT: prime-database-backup/
jobs:
build-backup:
runs-on: ubuntu-20.04
environment: Development
steps:
- name: "Checkout the repo"
uses: actions/checkout@v3
- name: "Login to OpenShift repository"
uses: docker/login-action@v2
with:
registry: ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}
username: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_USERNAME}}
password: ${{secrets.OPENSHIFT_TOOLS_SERVICE_ACCOUNT_PASSWORD}}
- name: "Build Backup image"
run: |
docker build -t ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ env.CONTEXT }} -f ${{ env.CONTEXT }}openshift.dockerfile
- name: "Docker tag and push Backup image"
run: |
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/${{ env.NAME }}:${{ env.INITIAL_TAG }}
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/${{ env.NAME }}:${{ env.TAG }}
docker push ${{secrets.OPENSHIFT_IMAGE_REPOSITORY}}/${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/${{ env.NAME }}:${{ env.TAG }}
apply-oc-template:
runs-on: ubuntu-20.04
environment: Development
needs: [build-backup]
steps:
- name: "Use the OpenShift template"
uses: actions/checkout@v3
- name: Install OC
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.6"
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1.1
with:
openshift_server_url: ${{secrets.OPENSHIFT_SERVER_URL}}
openshift_token: ${{secrets.OPENSHIFT_SERVICE_TOKEN}}
namespace: ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}}
- name: "Process template"
id: oc
run: |
oc process -f infrastructure/backup-container.yml \
-p NAME=backup \
-p SOURCE_CONTEXT_DIR=prime-database-backup \
-p SOURCE_REPOSITORY_URL=https://github.com/bcgov/moh-prime \
-p OC_NAMESPACE=${{secrets.OPENSHIFT_LICENSE_PLATE}} \
-p OC_APP=dev \
-p POSTGRESQL_HOST=postgresql \
-p METABASE_HOST=metabase-database | oc apply -n ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} -f -