-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (67 loc) · 2.4 KB
/
destroy-preview.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
76
77
78
79
80
name: Preview-Destroy
on:
pull_request:
types:
- closed
env:
ENVIRONMENT: test
OPENSHIFT_API: https://api.cloudscale-lpg-2.appuio.cloud:6443
HELM_RELEASE_NAME: odootools-pr-${{ github.event.number }}
IMG_TAG: pr-${{ github.event.number }}
NAMESPACE: vshn-odoo-test
jobs:
uninstall:
runs-on: ubuntu-latest
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
steps:
- uses: actions/checkout@v4
- name: Setup helmfile
uses: mamezou-tech/[email protected]
with:
helm-version: v3.7.1
helmfile-version: v0.142.0
install-kubectl: false
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ env.OPENSHIFT_API }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
namespace: ${{ env.NAMESPACE }}
- name: Uninstall app
run: make preview.destroy
env:
HELM_RELEASE_NAME: ${{ env.HELM_RELEASE_NAME }}
- name: Delete image in registry
run: oc -n ${{ env.NAMESPACE }} delete imagestreamtags odootools:${{ env.IMG_TAG }} --ignore-not-found
- name: Notify on success
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.number }}
body: |
## ✔️ Preview deployment uninstalled
| | |
|-|-|
**Helm release** | ${{ env.NAMESPACE }}/${{ env.HELM_RELEASE_NAME }}
**Cluster** | ${{ env.OPENSHIFT_API }}
- name: Notify on failure
uses: peter-evans/create-or-update-comment@v3
if: ${{ failure() }}
with:
issue-number: ${{ github.event.number }}
body: |
## ❌ Failed to remove preview deployment
| | |
|-|-|
**App URL** | https://${{ env.ROUTE_HOST }}
**Helm release** | ${{ env.NAMESPACE }}/${{ env.HELM_RELEASE_NAME }}
**Cluster** | ${{ env.OPENSHIFT_API }}
Please investigate what went wrong in the GitHub actions logs.
Maintainers can manually remove the deployment by running
```bash
make preview.destroy -e HELM_RELEASE_NAME=${{ env.HELM_RELEASE_NAME }}
oc -n ${{ env.NAMESPACE }} delete imagestreamtags odootools:${{ env.IMG_TAG }} --ignore-not-found
```