mirror of
https://github.com/anthropics/claude-code.git
synced 2026-02-19 04:27:33 -08:00
Compare commits
1 Commits
claude/sla
...
ashwin/loc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02a77c5897 |
85
.github/workflows/lock-closed-issues.yml
vendored
85
.github/workflows/lock-closed-issues.yml
vendored
@@ -13,16 +13,81 @@ concurrency:
|
|||||||
group: lock-threads
|
group: lock-threads
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lock-threads:
|
lock-closed-issues:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1
|
- name: Lock closed issues after 7 days of inactivity
|
||||||
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
issue-inactive-days: "7"
|
script: |
|
||||||
process-only: "issues"
|
const sevenDaysAgo = new Date();
|
||||||
log-output: true
|
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
||||||
issue-comment: >
|
|
||||||
This issue has been automatically locked since it was
|
const lockComment = `This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.`;
|
||||||
closed and has not had any activity for 7 days.
|
|
||||||
If you're experiencing a similar issue, please file a new issue
|
let page = 1;
|
||||||
and reference this one if it's relevant.
|
let hasMore = true;
|
||||||
|
let totalLocked = 0;
|
||||||
|
|
||||||
|
while (hasMore) {
|
||||||
|
// Get closed issues (pagination)
|
||||||
|
const { data: issues } = await github.rest.issues.listForRepo({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
state: 'closed',
|
||||||
|
sort: 'updated',
|
||||||
|
direction: 'asc',
|
||||||
|
per_page: 100,
|
||||||
|
page: page
|
||||||
|
});
|
||||||
|
|
||||||
|
if (issues.length === 0) {
|
||||||
|
hasMore = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const issue of issues) {
|
||||||
|
// Skip if already locked
|
||||||
|
if (issue.locked) continue;
|
||||||
|
|
||||||
|
// Skip pull requests
|
||||||
|
if (issue.pull_request) continue;
|
||||||
|
|
||||||
|
// Check if updated more than 7 days ago
|
||||||
|
const updatedAt = new Date(issue.updated_at);
|
||||||
|
if (updatedAt > sevenDaysAgo) {
|
||||||
|
// Since issues are sorted by updated_at ascending,
|
||||||
|
// once we hit a recent issue, all remaining will be recent too
|
||||||
|
hasMore = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Add comment before locking
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
body: lockComment
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lock the issue
|
||||||
|
await github.rest.issues.lock({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
lock_reason: 'resolved'
|
||||||
|
});
|
||||||
|
|
||||||
|
totalLocked++;
|
||||||
|
console.log(`Locked issue #${issue.number}: ${issue.title}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to lock issue #${issue.number}: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Total issues locked: ${totalLocked}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user