-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate preview + remove-preview workflows
- Loading branch information
1 parent
02fa4b1
commit e745a76
Showing
2 changed files
with
36 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Remove PR previews | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- closed | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
delete-preview-directory: | ||
if: github.event.action == 'closed' || github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout gh-pages branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: gh-pages | ||
|
||
- name: Remove PR Preview Directory | ||
run: | | ||
PR_NUMBER=${{ github.event.pull_request.number }} | ||
PREVIEW_DIR="pr-previews/${PR_NUMBER}" | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git pull origin gh-pages | ||
rm -rf ${PREVIEW_DIR} | ||
git add . | ||
git commit -m "Remove preview for merged PR #${PR_NUMBER}" | ||
git push |