-
Notifications
You must be signed in to change notification settings - Fork 11
52 lines (48 loc) · 1.69 KB
/
preview-remove.yaml
File metadata and controls
52 lines (48 loc) · 1.69 KB
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
name: Remove preview
on:
pull_request_target:
types: [ closed ]
env:
BUCKET_NAME: ds-preview-stac-map-${{ github.event.number }}
AWS_ROLE_ARN: arn:aws:iam::552819999234:role/stac-map-gh-preview
AWS_REGION: us-west-2
permissions:
id-token: write
contents: read
issues: write
pull-requests: write
jobs:
remove:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: Check if bucket exists
id: check_bucket
run: |
if aws s3 ls "s3://${{ env.BUCKET_NAME }}" 2>&1 | grep -q 'NoSuchBucket'; then
echo "Bucket does not exist."
echo "exists=false" >> "$GITHUB_OUTPUT"
else
echo "Bucket exists."
echo "exists=true" >> "$GITHUB_OUTPUT"
fi
- name: Empty the bucket
if: steps.check_bucket.outputs.exists == 'true'
run: |
aws s3 rm s3://$BUCKET_NAME --recursive --quiet
- name: Remove the bucket
if: steps.check_bucket.outputs.exists == 'true'
run: |
aws s3 rb s3://$BUCKET_NAME
- name: Remove PR comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
if: success()
with:
script: |
const { deleteComment } = require('./.github/workflows/github-pr-update.cjs')
await deleteComment({ github, context, core })