-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (42 loc) · 1.38 KB
/
pull-request-tear-down.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
43
44
45
name: ✳️ Pull request tear down
on:
workflow_dispatch:
pull_request:
types:
- closed
paths-ignore:
- '**.md'
jobs:
validate-deployment-or-teardown:
runs-on: ubuntu-latest
outputs:
valid: ${{ steps.validate.outputs.valid }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- id: validate
name: Validate branch eligibility for tear down
run: scripts/validate-deployment-or-teardown.sh ${{ github.head_ref }} >> $GITHUB_OUTPUT
tear-down-feature:
needs: [validate-deployment-or-teardown]
if: needs.validate-deployment-or-teardown.outputs.valid == 'true'
# These permissions are needed to interact with GitHub's OIDC Token endpoint (enabling the aws-actions/configure-aws-credentials action)
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Assume AWS role
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-2
role-to-assume: ${{ secrets.FEATURE_ENVIRONMENT_TEAR_DOWN_ROLE_ARN }}
- name: Prepare for stack deletion
run: npm run teardown:prepare
- name: Delete CF stack
run: npm run teardown:delete-stack