File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Close stale branches
2+ on :
3+ workflow_dispatch :
4+ schedule :
5+ - cron : ' 30 1 * * *' # run every day at 01:30 UTC
6+
7+ permissions :
8+ contents : read
9+
10+ jobs :
11+ stale-branches :
12+ runs-on : ubuntu-latest
13+ env :
14+ ORG : nginx
15+ REPO : documentation
16+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
17+ steps :
18+ - name : Get all stale branches
19+ run : |
20+ HAS_MORE=true
21+
22+ while [ "$HAS_NAME" = "true" ]; do
23+
24+ # Fetch stale branches
25+ RESPONSE=$(curl -L \
26+ -X GET \
27+ -H "Accept: application/json" \
28+ -s "https://github.com/${{env.ORG}}/${{env.REPO}}/branches/stale")
29+
30+ HAS_MORE=$(echo "$RESPONSE" | jq -r '.payload.has_more')
31+ BRANCHES=$(echo "$RESPONSE" | jq -r '.payload.branches[].name')
32+
33+ for BRANCH in $BRANCHES; do
34+ REF="heads/$BRANCH"
35+ echo $REF
36+ echo $HAS_MORE
37+ echo $BRANCH
38+ # DELETE_REPONSE=$(curl -L \
39+ # -X DELETE \
40+ # -H "Accept: application/vnd.github+json" \
41+ # -H "Authorization: Bearer ${{env.GITHUB_TOKEN}}" \
42+ # -H "X-GitHub-Api-Version: 2022-11-28" \
43+ # https://api.github.com/repos/${{env.ORG}}/${{env.REPO}}/git/refs/$REF)
44+
45+ done
46+ done
47+
48+
49+
50+ echo $RESPONSE
51+
You can’t perform that action at this time.
0 commit comments