-
Notifications
You must be signed in to change notification settings - Fork 3
75 lines (63 loc) · 2.64 KB
/
pr-teardown.yaml
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
name: PR Teardown on Dev
on:
pull_request:
types: [unlabeled, closed]
env:
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
PR_NUMBER: ${{ github.event.pull_request.number }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
install-oc:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- name: Check out repository
uses: actions/[email protected]
- name: Set up cache for OpenShift CLI
id: cache
uses: actions/[email protected]
with:
path: /usr/local/bin/oc # Path where the `oc` binary will be installed
key: oc-cli-${{ runner.os }}
- name: Install OpenShift CLI (if not cached)
if: steps.cache.outputs.cache-hit != 'true'
run: |
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz
tar -xvf openshift-client-linux.tar.gz
sudo mv oc /usr/local/bin/
oc version --client
- name: Confirm OpenShift CLI is Available
run: oc version --client
teardown:
if: >
(github.event.action == 'unlabeled' && github.event.label.name == 'build') ||
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'build') )
name: PR Teardown
runs-on: ubuntu-latest
needs: [install-oc]
timeout-minutes: 60
steps:
- name: Restore oc command from Cache
uses: actions/[email protected]
with:
path: /usr/local/bin/oc
key: oc-cli-${{ runner.os }}
- name: Log in to Openshift
uses: redhat-actions/[email protected]
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
insecure_skip_tls_verify: true
namespace: ${{ env.DEV_NAMESPACE }}
- name: Teardown the pull request
run: |
helm -n ${{ env.DEV_NAMESPACE }} uninstall lcfs-frontend-dev-${{ env.PR_NUMBER }}
helm -n ${{ env.DEV_NAMESPACE }} uninstall lcfs-backend-dev-${{ env.PR_NUMBER }}
helm -n ${{ env.DEV_NAMESPACE }} uninstall lcfs-redis-dev-${{ env.PR_NUMBER }}
helm -n ${{ env.DEV_NAMESPACE }} uninstall lcfs-postgres-dev-${{ env.PR_NUMBER }}
helm -n ${{ env.DEV_NAMESPACE }} uninstall lcfs-minio-dev-${{ env.PR_NUMBER }}
oc -n ${{ env.DEV_NAMESPACE }} delete pvc -l app.kubernetes.io/instance=lcfs-postgres-dev-${{ env.PR_NUMBER }}
oc -n ${{ env.DEV_NAMESPACE }} delete pvc -l app.kubernetes.io/instance=lcfs-redis-dev-${{ env.PR_NUMBER }}