generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (107 loc) · 4.04 KB
/
pr-open.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: PR
on:
pull_request:
concurrency:
# Cancel in progress for PR open and close
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
# https://github.com/bcgov-nr/action-builder-ghcr
builds:
name: Builds
runs-on: ubuntu-22.04
permissions:
packages: write
outputs:
digest: ${{ steps.builds.outputs.digest }}
sha: ${{ github.sha }}
strategy:
matrix:
package: [migrations, backend]
timeout-minutes: 10
steps:
- uses: bcgov-nr/[email protected]
id: builds
with:
keep_versions: 50
package: ${{ matrix.package }}
tag: ${{ github.event.number }}
tag_fallback: latest
triggers: ('${{ matrix.package }}/')
- uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ github.event.number }}
tags: |
${{ github.sha }}
# https://github.com/bcgov-nr/action-deployer-openshift
deploys:
name: Deploys
needs: [builds]
environment: dev
runs-on: ubuntu-22.04
steps:
- name: Checkout CD repo
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-dc0a4a
ssh-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }}
ref: main
- name: Calculate Deployment Number
id: get-deployment-number
shell: bash
run: |
PR_NUMBER=$(echo ${{ github.event.number }})
PR_NUMBER_MOD_FIVE=$(($PR_NUMBER % 5))
echo "DEPLOYMENT_NUMBER=$(($PR_NUMBER_MOD_FIVE + 1))" >> $GITHUB_OUTPUT
- 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: |
DEPLOYMENT_NUMBER=${{ steps.get-deployment-number.outputs.DEPLOYMENT_NUMBER }}
cd charts/nr-compliance-enforcement-cm
yq eval '.global.enabled=true' -i values-"$DEPLOYMENT_NUMBER".yaml
yq eval '.global.tag="${{ needs.builds.outputs.sha }}"' -i values-"$DEPLOYMENT_NUMBER".yaml
- name: Commit and push update
shell: bash
run: |
git commit -am "Update image tag for pull request deployment and enable it for values-${{ steps.get-deployment-number.outputs.DEPLOYMENT_NUMBER }}.yaml"
git push origin main
validate:
name: Validate
needs: [deploys]
if: always() && (!cancelled()) && (!failure())
env:
DOMAIN: apps.emerald.devops.gov.bc.ca
PREFIX: ${{ github.event.repository.name }}
permissions:
pull-requests: write
runs-on: ubuntu-22.04
steps:
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: failure()
run: |
echo "Please use conventional commits in your PR title and re-run this job."
echo "https://www.conventionalcommits.org/en/v1.0.0/"
exit 1
- uses: bcgov-nr/[email protected]
env:
DOMAIN: apps.silver.devops.gov.bc.ca
PREFIX: ${{ github.event.repository.name }}
with:
add_markdown: |
---
Thanks for the PR!
Deployments, as required, will be available below:
- [Backend](https://${{ env.PREFIX }}-${{ github.event.number }}-backend.${{ env.DOMAIN }}/api)
Please create PRs in draft mode. Mark as ready to enable:
- [Analysis Workflow](https://github.com/${{ github.repository }}/actions/workflows/analysis.yml)
After merge, new images are deployed in:
- [Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge.yml)