Repository navigation
87 lines (80 loc) · 3.32 KB
/
Copy pathstale.yml
File metadata and controls
87 lines (80 loc) · 3.32 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
name: 🧹 Stale PRs
# Close stale pull requests after a period of inactivity.
# Runs daily at 9:00 UTC. Can also be triggered manually.
on:
schedule:
- cron: "0 9 * * *"
workflow_dispatch:
permissions:
issues: write
pull-requests: write
jobs:
stale:
runs-on: "${{ vars.CI_RUNNER_SMALL || 'ubuntu-latest' }}"
steps:
# actions/stale can't filter by author, so we translate "team member's
# draft" into a label that exempt-pr-labels understands. External drafts
# are left unlabeled and therefore processed like any other PR.
- name: Exempt team-member draft PRs
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
script: |
const TEAM = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
const LABEL = "team-draft";
const prs = await github.paginate(github.rest.pulls.list, {
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
per_page: 100,
});
for (const pr of prs) {
const shouldExempt = pr.draft && TEAM.has(pr.author_association);
const hasLabel = pr.labels.some((l) => l.name === LABEL);
if (shouldExempt && !hasLabel) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: [LABEL],
});
} else if (!shouldExempt && hasLabel) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
name: LABEL,
});
}
}
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9
with:
# --- General ---
repo-token: ${{ secrets.GITHUB_TOKEN }}
operations-per-run: 60
# --- Pull Requests ---
days-before-stale: 30
days-before-close: 14
stale-pr-label: "stale"
stale-pr-message: >
This pull request has been automatically marked as stale because it
has not had activity in 30 days. It will be closed in 14 days if no
further activity occurs. If this PR is still relevant, please leave
a comment or push new changes to keep it open. Thank you for your
contribution!
close-pr-message: >
This pull request has been automatically closed due to inactivity.
Feel free to reopen it if you'd like to continue working on it.
close-pr-label: "closed-stale"
# Process external drafts; team drafts are exempted via the
# "team-draft" label applied in the step above.
exempt-draft-pr: false
# Don't touch issues with this workflow
days-before-issue-stale: -1
days-before-issue-close: -1
# Exempt PRs with these labels
exempt-pr-labels: "do-not-close,work-in-progress,pinned,team-draft"
# Remove stale label when PR is updated
remove-stale-when-updated: true
# --- Rate Limiting ---
# Ascending order processes oldest first
ascending: true