generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (58 loc) · 1.95 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
57
58
59
60
61
62
63
64
65
66
name: Pull Request Closed
on:
pull_request:
types:
- closed
paths-ignore:
- ".github/ISSUE_TEMPLATE/*"
- "**.md"
env:
name: nr-ticdi
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Clean up OpenShift when PR closed, no conditions
cleanup-openshift:
name: Cleanup OpenShift
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Remove OpenShift artifacts
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }}
# Remove old build runs, build pods and deployment pods
oc delete all -l app=${{ env.name }}-${{ github.event.number }}
# If merged into main, then handle any image promotions
image-promotions:
name: Image Promotions
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
uses: ./.github/workflows/_image_promote.yml
strategy:
matrix:
component: [backend, frontend]
with:
app_name: nr-ticdi
component: ${{ matrix.component }}
env_source: ${{ github.event.number }}
env_target: test
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_server: ${{ secrets.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
# Notify when PR merged into main
merge-notification:
name: Merge Notification
runs-on: ubuntu-22.04
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
steps:
- name: Pre-merge update
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }}
with:
allow-repeats: false
message: |
Your Pull Request code is being promoted! Please follow the link below.
[Main Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge-main.yml)