File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Delete GitHub Repo
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ repo_owner :
7+ description : ' Owner of the repo (user or org)'
8+ required : true
9+ repo_name :
10+ description : ' Name of the repo to delete'
11+ required : true
12+
13+ jobs :
14+ delete_repo :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Delete GitHub repository
18+ env :
19+ GH_TOKEN : ${{ secrets.COMMITTER_TOKEN }} # Inject your custom token here
20+ REPO_OWNER : ${{ github.event.inputs.repo_owner }}
21+ REPO_NAME : ${{ github.event.inputs.repo_name }}
22+ run : |
23+ echo "🔴 Attempting to delete repository: $REPO_OWNER/$REPO_NAME"
24+
25+ response=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE \
26+ -H "Authorization: token $GH_TOKEN" \
27+ -H "Accept: application/vnd.github+json" \
28+ "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME")
29+
30+ if [ "$response" == "204" ]; then
31+ echo "✅ Repository $REPO_OWNER/$REPO_NAME successfully deleted."
32+ else
33+ echo "❌ Failed to delete repo. HTTP status: $response"
34+ exit 1
35+ fi
You can’t perform that action at this time.
0 commit comments