Skip to content

Commit

Permalink
Create pr-close.yaml
Browse files Browse the repository at this point in the history
remove previews when closed
  • Loading branch information
sammachin committed Mar 14, 2024
1 parent d944419 commit c57c827
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/pr-close.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Remove PR previews when PR is closed

on:
pull_request_target:
types:
- closed

concurrency: preview-${{ github.ref }}

permissions:
contents: write
pull-requests: write

defaults:
run:
shell: bash

jobs:
remove:
if: github.repository == 'project-chip/matter-handbook'
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.115.4
steps:
- name: Remove from S3
uses: vitorsgomes/s3-rm-action@master
with:
args: --recursive
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "us-east-1"
PATH_TO_DELETE: 'pr-${{ github.event.number }}'
- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.AWS_CF_DISTRIBUTION }}
PATHS: '/pr-${{ github.event.number }}/*'
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Preview deployed at ${{ vars.PREVIEW_URL }}/pr-${{ github.event.number }}

0 comments on commit c57c827

Please sign in to comment.