-
-
Notifications
You must be signed in to change notification settings - Fork 8
42 lines (36 loc) · 1.28 KB
/
pr-cleanup.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
name: PR Cleanup
on:
pull_request:
types: [closed, unlabeled]
env:
DEPLOY_NAMESPACE: doctors-pr
RELEASE_NAME: website-pr-${{ github.event.pull_request.number }}
DEPLOY_ENV: pr-${{ github.event.pull_request.number }}
jobs:
check:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Check if PR is labeled
id: label
run: echo ::set-output name=has_label::${{ contains(github.event.pull_request.labels.*.name, 'deploy-preview') }}
- name: Check if PR is deployed
id: http
run: echo ::set-output name=status_code::$(curl -o /dev/null -s -k -w "%{http_code}\n" https://pr-${{ github.event.pull_request.number }}.preview.sledilnik.org)
outputs:
status_code: ${{ steps.http.outputs.status_code }}
has_label: ${{ steps.label.outputs.has_label }}
undeploy:
runs-on: ubuntu-latest
needs: [check]
if: "needs.check.status_code != '404' && (github.event.action == 'closed' || !needs.check.has_label)"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Undeploy
uses: sledilnik/[email protected]
with:
action: undeploy
chartName: sledilnik/website
chartVersion: '0.9.0'
kubeconfig: '${{ secrets.KUBECONFIG }}'