Skip to content

Update gh_pages_doc.yml #1

Update gh_pages_doc.yml

Update gh_pages_doc.yml #1

name: Cleanup PR Previews
on:
pull_request:
types:
- closed # Trigger when a PR is closed (merged or not)
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Ensure full history and all branches are fetched
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Delete PR preview folder
run: |
pr_number=${{ github.event.pull_request.number }}
branch=gh-pages
# Fetch the gh-pages branch
git fetch origin $branch
git checkout $branch
# Remove the pr-<PR_NUMBER> folder
if [ -d "pr-$pr_number" ]; then
git rm -r --cached "pr-$pr_number"
rm -rf "pr-$pr_number"
git commit -m "Remove PR preview for PR #$pr_number"
git push origin $branch
echo "PR preview folder pr-$pr_number deleted from $branch."
else
echo "PR preview folder pr-$pr_number not found. Skipping."
fi