-
Notifications
You must be signed in to change notification settings - Fork 2
42 lines (42 loc) · 1.39 KB
/
branch-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: Branch Cleanup
on:
delete:
branches:
# all branches created from issue
- "[0-9]+-**"
jobs:
cleanup:
name: Clean up S3
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
AWS_REGION: "eu-central-1"
steps:
- name: Extract branch name
shell: bash
run: |
BRANCH=$(cat ${{ github.event_path }} | jq --raw-output '.ref')
echo "branch=${BRANCH#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Remove from S3
uses: vitorsgomes/s3-rm-action@master
with:
args: --recursive
env:
AWS_S3_BUCKET: "ideapool-aws-testing"
PATH_TO_DELETE: ${{ steps.extract_branch.outputs.branch }}
- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: "E2GO9UW2P84E3I"
PATHS: "/${{ steps.extract_branch.outputs.branch }}/*"
- uses: strumwolf/delete-deployment-environment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: aws-development
ref: ${{ steps.extract_branch.outputs.branch }}
onlyDeactivateDeployments: true
- name: Output
run: |
echo "✔ Branch is successfully cleaned from AWS" >> $GITHUB_STEP_SUMMARY