Skip to content

Commit f6b9348

Browse files
authored
Merge pull request #38 from squaredup/work/ss/pr-plugin-cleanup
New Workflow to CleanUp Plugins on PR Close
2 parents 172f66c + 0284a8c commit f6b9348

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/pr-cleanup.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Cleanup PR Plugins
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
cleanup:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Install & Configure SquaredUp CLI
12+
env:
13+
SQUAREDUP_API_KEY: ${{ secrets.SQUAREDUP_API_KEY }}
14+
run: |
15+
npm install -g @squaredup/cli
16+
squaredup login --apiKey "$SQUAREDUP_API_KEY"
17+
18+
- name: Delete PR plugins
19+
run: |
20+
pr_number="${{ github.event.pull_request.number }}"
21+
echo "Looking for plugins deployed by PR #${pr_number}..."
22+
23+
plugins=$(squaredup list --json)
24+
matches=$(echo "$plugins" | jq -r --arg pr "-${pr_number}" '.[] | select(.displayName | endswith($pr)) | .id')
25+
26+
if [ -z "$matches" ]; then
27+
echo "No plugins found for PR #${pr_number}."
28+
exit 0
29+
fi
30+
31+
while IFS= read -r id; do
32+
name=$(echo "$plugins" | jq -r --arg id "$id" '.[] | select(.id == $id) | .displayName')
33+
echo "Deleting '${name}' (${id})..."
34+
squaredup delete "${id}"
35+
done <<< "$matches"

0 commit comments

Comments
 (0)