-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (57 loc) · 1.81 KB
/
feature-branch-nuke.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
name: "Feature branch Nuke"
on:
pull_request:
types:
- closed
workflow_call:
inputs:
prNumber:
required: true
type: string
githubRef:
required: true
type: string
gitSha:
required: true
type: string
secrets:
AWS_ACCOUNT_ID:
required: true
GH_AWS_ACCESS_KEY_ID:
required: true
GH_AWS_SECRET_ACCESS_KEY:
required: true
jobs:
nuke:
runs-on: ubuntu-latest
if: startsWith(github.event.pull_request.base.ref, 'feat/') == true
steps:
- uses: actions/checkout@v2
- id: synth
name: Synth cdk8s manifests
run: |-
cd k8s
yarn install --frozen-lockfile
# Feature Branch nuke set-up
export DEPLOY_TO_FEATURE_BRANCH=true
export RELEASE_NAME=${REPOSITORY#*/}-pr-$PR_NUMBER
# Export RELEASE_NAME as an output
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_OUTPUT
yarn build
env:
PR_NUMBER: ${{ inputs.prNumber }}
GIT_REF: ${{ inputs.githubRef }}
GIT_SHA: ${{ inputs.gitSha }}
REPOSITORY: ${{ github.repository }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
- name: Nuke
run: |-
aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/kubectl
# Get repo name from synth step
RELEASE_NAME=${{ steps.synth.outputs.RELEASE_NAME }}
# Delete all non-certificate resources
kubectl delete -f k8s/dist/ -l app.kubernetes.io/part-of=$RELEASE_NAME
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.GH_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.GH_AWS_SECRET_ACCESS_KEY }}