mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-05 09:30:32 +08:00
5da9dde184
Some checks are pending
Publish Any Commit / build (push) Waiting to run
🔀 Sync mirror to Gitee / mirror (push) Waiting to run
✅ test / lint (push) Waiting to run
✅ test / test-react-legacy (16, 1/2) (push) Waiting to run
✅ test / test-react-legacy (16, 2/2) (push) Waiting to run
✅ test / test-react-legacy (17, 1/2) (push) Waiting to run
✅ test / test-react-legacy (17, 2/2) (push) Waiting to run
✅ test / test-node (push) Waiting to run
✅ test / test-react-latest (dom, 1/2) (push) Waiting to run
✅ test / test-react-latest (dom, 2/2) (push) Waiting to run
✅ test / test-react-latest-dist (dist, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist, 2/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Blocked by required conditions
✅ test / test-coverage (push) Blocked by required conditions
✅ test / build (push) Waiting to run
✅ test / test lib/es module (es, 1/2) (push) Waiting to run
✅ test / test lib/es module (es, 2/2) (push) Waiting to run
✅ test / test lib/es module (lib, 1/2) (push) Waiting to run
✅ test / test lib/es module (lib, 2/2) (push) Waiting to run
👁️ Visual Regression Persist Start / test image (push) Waiting to run
* ci: add auto unassign workflow * fix: update auto unassign workflow to increase inactivity threshold to 14 days and improve comment messaging
80 lines
2.8 KiB
YAML
80 lines
2.8 KiB
YAML
name: Auto Unassign
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 0 * * *" # Run at 00:00 every day
|
|
|
|
permissions:
|
|
issues: write # Need write permission to modify issue assignees
|
|
|
|
jobs:
|
|
unassign_job:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Unassign inactive issues
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const daysBeforeUnassign = 14;
|
|
let page = 1;
|
|
const perPage = 100;
|
|
|
|
while (true) {
|
|
const { data: issues } = await github.rest.issues.listForRepo({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
state: 'open',
|
|
assignee: '*', // Filter assigned issues
|
|
per_page: perPage,
|
|
page: page,
|
|
});
|
|
|
|
if (issues.length === 0) {
|
|
break;
|
|
}
|
|
|
|
const now = new Date();
|
|
|
|
for (const issue of issues) {
|
|
if (issue.pull_request) continue;
|
|
|
|
const updatedAt = new Date(issue.updated_at);
|
|
const daysInactive = (now - updatedAt) / (1000 * 60 * 60 * 24);
|
|
|
|
const { data: timeline } = await github.rest.issues.listEventsForTimeline({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue.number,
|
|
});
|
|
|
|
const hasLinkedPR = timeline.some(event =>
|
|
event.event === 'cross-referenced' && event.source?.issue?.pull_request || // PR referenced this issue
|
|
event.event === 'connected' || // PR connected via keywords
|
|
event.event === 'referenced' && event.commit_id // Connected via commit
|
|
);
|
|
|
|
if (daysInactive >= daysBeforeUnassign && !hasLinkedPR) {
|
|
const assigneesMentions = issue.assignees
|
|
.map(user => `@${user.login}`)
|
|
.join(' ');
|
|
|
|
// Remove assignees
|
|
await github.rest.issues.removeAssignees({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue.number,
|
|
assignees: issue.assignees.map(user => user.login),
|
|
});
|
|
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue.number,
|
|
body: `${assigneesMentions} Assignees have been automatically removed since no PR was linked to this issue within 14 days. Please contact maintainers for reassignment if you wish to continue working on this issue.`,
|
|
});
|
|
}
|
|
}
|
|
|
|
page += 1;
|
|
}
|