diff --git a/.github/workflows/DoodleBUGSPreviewCleanup.yml b/.github/workflows/DoodleBUGSPreviewCleanup.yml new file mode 100644 index 000000000..f248490b0 --- /dev/null +++ b/.github/workflows/DoodleBUGSPreviewCleanup.yml @@ -0,0 +1,36 @@ +name: DoodleBUGS PR Preview Cleanup + +on: + pull_request: + types: [closed] + paths: + - 'DoodleBUGS/**' + - '.github/workflows/DoodleBUGSpreview.yml' + - '.github/workflows/DoodleBUGSPreviewCleanup.yml' + +permissions: + contents: write + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Checkout gh-pages branch + uses: actions/checkout@v4 + with: + ref: gh-pages + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Delete DoodleBUGS preview and push changes + run: | + if [ -d "DoodleBUGS/pr-previews/$PRNUM" ]; then + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git rm -rf "DoodleBUGS/pr-previews/$PRNUM" + git commit -m "DoodleBUGS: Delete preview for PR $PRNUM" + git push origin gh-pages + else + echo "No DoodleBUGS preview found for PR $PRNUM" + fi + env: + PRNUM: ${{ github.event.number }} \ No newline at end of file