2023-02-24 23:44:35 +03:00
|
|
|
# cleans up our S3 staging area if a PR is closed without merge
|
|
|
|
|
2023-09-30 19:15:42 +03:00
|
|
|
name: pkgx/s3-cleanup
|
2023-03-16 15:33:53 +03:00
|
|
|
run-name: 'cleanup: ${{ github.event.pull_request.title }}'
|
2023-02-24 23:44:35 +03:00
|
|
|
|
2022-12-21 00:54:01 +03:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types: [closed]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cleanup:
|
|
|
|
runs-on: ubuntu-latest
|
2023-02-04 03:52:04 +03:00
|
|
|
if: github.event.pull_request.merged == false
|
2022-12-21 00:54:01 +03:00
|
|
|
steps:
|
|
|
|
- name: Configure AWS Credentials
|
|
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
|
|
with:
|
|
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
|
|
aws-region: us-east-1
|
2023-02-24 23:44:35 +03:00
|
|
|
|
2022-12-21 00:54:01 +03:00
|
|
|
- name: remove staged artifacts
|
|
|
|
run: |
|
2023-09-30 19:15:42 +03:00
|
|
|
REPO=$(echo ${{github.repository}} | sed -e 's_pkgxdev/__')
|
2022-12-21 00:54:01 +03:00
|
|
|
PR=$(echo ${{github.ref}} | sed -e 's_refs/pull/\(.*\)/merge_\1_')
|
|
|
|
|
|
|
|
aws s3 rm --recursive s3://$AWS_S3_CACHE/pull-request/$REPO/$PR
|
2023-09-30 19:15:42 +03:00
|
|
|
if: startsWith(github.ref, 'refs/pull/') && github.repository_owner == 'pkgxdev'
|
2022-12-21 00:54:01 +03:00
|
|
|
env:
|
|
|
|
AWS_S3_CACHE: ${{ secrets.AWS_S3_CACHE }}
|