From 0284a8c721ee0683ab5a5eaf70c52429fd577362 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Mon, 13 Apr 2026 14:06:42 +0100 Subject: [PATCH] feat: workflow to cleanup plugins deployed from PR --- .github/workflows/pr-cleanup.yaml | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/pr-cleanup.yaml diff --git a/.github/workflows/pr-cleanup.yaml b/.github/workflows/pr-cleanup.yaml new file mode 100644 index 0000000..aef5372 --- /dev/null +++ b/.github/workflows/pr-cleanup.yaml @@ -0,0 +1,35 @@ +name: Cleanup PR Plugins + +on: + pull_request: + types: [closed] + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Install & Configure SquaredUp CLI + env: + SQUAREDUP_API_KEY: ${{ secrets.SQUAREDUP_API_KEY }} + run: | + npm install -g @squaredup/cli + squaredup login --apiKey "$SQUAREDUP_API_KEY" + + - name: Delete PR plugins + run: | + pr_number="${{ github.event.pull_request.number }}" + echo "Looking for plugins deployed by PR #${pr_number}..." + + plugins=$(squaredup list --json) + matches=$(echo "$plugins" | jq -r --arg pr "-${pr_number}" '.[] | select(.displayName | endswith($pr)) | .id') + + if [ -z "$matches" ]; then + echo "No plugins found for PR #${pr_number}." + exit 0 + fi + + while IFS= read -r id; do + name=$(echo "$plugins" | jq -r --arg id "$id" '.[] | select(.id == $id) | .displayName') + echo "Deleting '${name}' (${id})..." + squaredup delete "${id}" + done <<< "$matches"