-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (29 loc) · 1.06 KB
/
pr-cleanup.yaml
File metadata and controls
35 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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"