-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdelete-all-hacktoberfest-issues.yml
More file actions
104 lines (85 loc) · 3.92 KB
/
Copy pathdelete-all-hacktoberfest-issues.yml
File metadata and controls
104 lines (85 loc) · 3.92 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Delete ALL Hacktoberfest Issues (Open + Closed)
on:
workflow_dispatch:
inputs:
confirm:
description: 'Type "DELETE-ALL-PERMANENTLY" to confirm permanent deletion of ALL (open + closed) Hacktoberfest issues'
required: true
type: string
jobs:
delete-all-issues:
name: Permanently delete ALL Hacktoberfest issues (open and closed)
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- name: Validate confirmation
run: |
if [ "${{ github.event.inputs.confirm }}" != "DELETE-ALL-PERMANENTLY" ]; then
echo "❌ Confirmation failed. You must type 'DELETE-ALL-PERMANENTLY' to proceed."
exit 1
fi
echo "✓ Confirmation validated - proceeding with permanent deletion of ALL issues"
- name: Delete ALL Hacktoberfest issues (open and closed)
env:
REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
echo "⚠️⚠️⚠️ WARNING: This will PERMANENTLY DELETE ALL Hacktoberfest issues (BOTH OPEN AND CLOSED)"
total_deleted=0
# Process OPEN issues
echo ""
echo "========================================="
echo "STEP 1: Fetching OPEN issues..."
echo "========================================="
open_issues=$(curl -sS -H "Authorization: token $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO/issues?state=open&labels=hacktoberfest&per_page=100")
open_count=$(echo "$open_issues" | jq '. | length')
echo "Found $open_count OPEN Hacktoberfest issues"
if [ "$open_count" -gt 0 ]; then
echo "$open_issues" | jq -r '.[].number' | while read -r issue_num; do
issue_title=$(echo "$open_issues" | jq -r ".[] | select(.number == $issue_num) | .title")
echo "🗑️ Deleting OPEN issue #$issue_num: $issue_title"
gh issue delete "$issue_num" --repo "$REPO" --yes
if [ $? -eq 0 ]; then
echo "✓ Deleted OPEN issue #$issue_num"
else
echo "✗ Failed to delete issue #$issue_num"
fi
done
fi
# Process CLOSED issues
echo ""
echo "========================================="
echo "STEP 2: Fetching CLOSED issues..."
echo "========================================="
closed_issues=$(curl -sS -H "Authorization: token $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO/issues?state=closed&labels=hacktoberfest&per_page=100")
closed_count=$(echo "$closed_issues" | jq '. | length')
echo "Found $closed_count CLOSED Hacktoberfest issues"
if [ "$closed_count" -gt 0 ]; then
echo "$closed_issues" | jq -r '.[].number' | while read -r issue_num; do
issue_title=$(echo "$closed_issues" | jq -r ".[] | select(.number == $issue_num) | .title")
echo "🗑️ Deleting CLOSED issue #$issue_num: $issue_title"
gh issue delete "$issue_num" --repo "$REPO" --yes
if [ $? -eq 0 ]; then
echo "✓ Deleted CLOSED issue #$issue_num"
else
echo "✗ Failed to delete issue #$issue_num"
fi
done
fi
total_deleted=$((open_count + closed_count))
echo ""
echo "========================================="
echo "DELETION SUMMARY"
echo "========================================="
echo "Open issues deleted: $open_count"
echo "Closed issues deleted: $closed_count"
echo "Total issues deleted: $total_deleted"
echo ""
echo "⚠️ Note: Deleted issues cannot be recovered!"