-
Notifications
You must be signed in to change notification settings - Fork 60
62 lines (54 loc) · 1.98 KB
/
clean.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
name: Cleanup
on:
pull_request:
types: [closed, unlabeled]
branches:
- maintenance-3.0.x
workflow_dispatch:
inputs:
branch_name:
description: 'The name of the branch to preview.'
default: 'maintenance-3.0.x'
required: true
caller_id:
description: 'run identifier'
default: 'maintenance-3.0.x'
type: string
required: false
env:
GKE_CLUSTER: jx-prod
GKE_ZONE: us-east1-b
jobs:
id:
name: Remote Caller ID ${{ github.event.inputs.caller_id }}
runs-on: ubuntu-latest
steps:
- name: ${{ github.event.inputs.id }}
run: echo run identifier ${{ github.event.inputs.id }}
cleanup:
needs: id
name: Preview
if: (github.event.action == 'unlabeled' && github.event.label.name == 'preview') || contains(github.event.pull_request.labels.*.name, 'preview') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Prepare environment (pull_request)
if: github.event_name == 'pull_request'
run: |
BRANCH_NAME=${GITHUB_HEAD_REF##*/}
echo "PREVIEW_NAMESPACE=$(printf '%.53s' $(echo nuxeo-web-ui-$(echo $BRANCH_NAME | sed 's/[^[:alnum:]-]/-/g' | tr '[:upper:]' '[:lower:]')))" >> $GITHUB_ENV
- name: Prepare environment (workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
BRANCH_NAME=${{ github.event.inputs.branch_name }}
echo "PREVIEW_NAMESPACE=$(printf '%.53s' $(echo nuxeo-web-ui-$(echo $BRANCH_NAME | sed 's/[^[:alnum:]-]/-/g' | tr '[:upper:]' '[:lower:]')))" >> $GITHUB_ENV
- name: Get GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
project_id: ${{ secrets.GKE_PROJECT }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Cleanup preview namespace
continue-on-error: true
run: |
kubectl delete ns ${PREVIEW_NAMESPACE}