You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: "Manage Stale Issues, PRs & Unmerged Branches"
2
2
on:
3
3
schedule:
4
-
- cron: '30 1 * * *'
5
-
4
+
- cron: '30 1 * * *'# Runs daily at 1:30 AM UTC
5
+
workflow_dispatch: # Allows manual triggering
6
6
permissions:
7
7
contents: write
8
8
issues: write
9
9
pull-requests: write
10
-
11
10
jobs:
12
11
stale:
13
12
runs-on: ubuntu-latest
14
13
steps:
15
-
- uses: actions/stale@v9
14
+
- name: Mark Stale Issues and PRs
15
+
uses: actions/stale@v9
16
16
with:
17
-
stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.'
17
+
stale-issue-message: "This issue is stale because it has been open 180 days with no activity. Remove stale label or comment, or it will be closed in 30 days."
18
+
stale-pr-message: "This PR is stale because it has been open 180 days with no activity. Please update or it will be closed in 30 days."
18
19
days-before-stale: 180
19
-
days-before-close: 30
20
+
days-before-close: 30
21
+
exempt-issue-labels: "keep"
22
+
exempt-pr-labels: "keep"
23
+
cleanup-branches:
24
+
runs-on: ubuntu-latest
25
+
steps:
26
+
- name: Checkout Repository
27
+
uses: actions/checkout@v4
28
+
with:
29
+
fetch-depth: 0# Fetch full history for accurate branch checks
30
+
- name: Fetch All Branches
31
+
run: git fetch --all --prune
32
+
- name: List Merged Branches With No Activity in Last 3 Months
33
+
run: |
34
+
35
+
echo "Branch Name,Last Commit Date,Committer,Committed In Branch,Action" > merged_branches_report.csv
36
+
37
+
for branch in $(git for-each-ref --format '%(refname:short) %(committerdate:unix)' refs/remotes/origin | awk -v date=$(date -d '3 months ago' +%s) '$2 < date {print $1}'); do
38
+
if [[ "$branch" != "origin/main" && "$branch" != "origin/dev" ]]; then
39
+
branch_name=${branch#origin/}
40
+
# Ensure the branch exists locally before getting last commit date
- name: List Open PR Branches With No Activity in Last 3 Months
62
+
run: |
63
+
64
+
for branch in $(gh api repos/${{ github.repository }}/pulls --state open --jq '.[] | select(.base.ref == "main" or .base.ref == "dev") | .head.ref'); do
65
+
# Ensure the branch exists locally before getting last commit date
0 commit comments