generated from bcgov/quickstart-openshift-emerald
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (96 loc) · 3.18 KB
/
merge.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Merge
on:
push:
branches: [main]
paths-ignore:
- '*.md'
- '.github/**'
- '.graphics/**'
- '!.github/workflows/**'
workflow_dispatch:
inputs:
pr_no:
description: "PR-numbered container set to deploy"
type: number
required: true
jobs:
vars:
name: Set Variables
outputs:
pr: ${{ steps.pr.outputs.pr }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
# Get PR number for squash merges to main
- name: PR Number
id: pr
uses: bcgov-nr/[email protected]
deploy-test:
name: Deploy (test)
needs: [vars]
runs-on: ubuntu-22.04
steps:
- name: Checkout CD repo
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-a7469b
ssh-key: ${{ secrets.DEPLOY_KEY }}
ref: main
- name: Configure git
# From https://github.com/orgs/community/discussions/26560#discussioncomment-3531273
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Update image tag And Enable it for deployment
run: |
cd charts/quickstart-openshift-emerald
yq eval '.global.tag="${{ needs.vars.outputs.pr }}"' -i values.yaml
- name: Commit and push update
shell: bash
run: |
git commit -am "Update image tag for pull request deployment and enable it for values.yaml for TEST deployment"
git push origin main
deploy-prod:
name: Deploy (prod)
needs: [deploy-test, vars]
runs-on: ubuntu-22.04
steps:
- name: Checkout CD repo
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-a7469b
ssh-key: ${{ secrets.DEPLOY_KEY }}
ref: main
- name: Configure git
# From https://github.com/orgs/community/discussions/26560#discussioncomment-3531273
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Update image tag And Enable it for deployment
run: |
cd charts/quickstart-openshift-emerald
yq eval '.global.tag="${{ needs.vars.outputs.pr }}"' -i values-prod.yaml
- name: Commit and push update
shell: bash
run: |
git commit -am "Update image tag for pull request deployment and enable it for values-prod.yaml for PROD deployment"
git push origin main
promote:
name: Promote Images
needs: [deploy-prod, vars]
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [migrations, backend, frontend]
timeout-minutes: 1
steps:
- uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ needs.vars.outputs.pr }}
tags: prod