generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (47 loc) · 1.91 KB
/
pr-close.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
name: PR Closed
on:
pull_request:
types: [closed]
concurrency:
# PR open and close use the same group, allowing only one at a time
group: pr-${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
# Clean up OpenShift when PR closed, no conditions
cleanup-openshift:
name: Cleanup OpenShift
runs-on: ubuntu-22.04
steps:
- name: Setup gitops repo access
uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }}
- 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=false' -i values-"$DEPLOYMENT_NUMBER".yaml
- name: Commit and push update
shell: bash
run: |
git commit -am "removing the deployment and disable it for values-${{ steps.get-deployment-number.outputs.DEPLOYMENT_NUMBER }}.yaml"
git push origin main