# This workflow removes any assets created for manual QA testing
# from the GitHub Wiki repository once a pull request is closed.
#
# See https://github.com/google/web-stories-wp/issues/1398

name: Clean up PR assets for closed PRs

on:
  pull_request:
    types: [closed]

jobs:
  remove-pr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          repository: ${{ github.repository }}.wiki
          ref: main
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Prune PR files
        run: |
          rm -rf "refs/pull/${{ github.event.pull_request.number }}"
          git add .
          git status
          git diff --staged --quiet && echo 'No changes to commit; exiting!' && exit 0
          git commit -m "Prune refs/pull/${{ github.event.pull_request.number }}"
          git pull --rebase
          git push origin main
        env:
          GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
          GIT_AUTHOR_NAME: ${{ github.actor }}
          GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
          GIT_COMMITTER_NAME: ${{ github.actor }}

# This workflow removes any assets created for manual QA testing
# from the GitHub Wiki repository once a pull request is closed.
#
# See https://github.com/google/web-stories-wp/issues/1398

name: Clean up PR assets for closed PRs

on:
  pull_request:
    types: [closed]

jobs:
  remove-pr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          repository: ${{ github.repository }}.wiki
          ref: master
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Prune PR files
        run: |
          rm -rf "refs/pull/${{ github.event.pull_request.number }}"
          git add .
          git status
          git diff --staged --quiet && echo 'No changes to commit; exiting!' && exit 0
          git commit -m "Prune refs/pull/${{ github.event.pull_request.number }}"
          git pull --rebase
          git push origin main
        env:
          GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
          GIT_AUTHOR_NAME: ${{ github.actor }}
          GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
          GIT_COMMITTER_NAME: ${{ github.actor }}

Undo change to remove-pr step
Undo change to remove-pr step

The wiki repo is not (yet) using the new default branch name
