Skip to content

Commit a4e54ea

Browse files
committed
ci: fix action pins and skip assignment when an item is already owned
Addresses review feedback on #1260: * actions/checkout was pinned to v5.0.0 in the classify job while every other workflow in the repo uses v7.0.1. Restored to v7.0.1. * actions/github-script was pinned to 373c709c, which is the v9 annotated tag object rather than a commit, so the ref did not resolve. Replaced with 3a2844b7, the commit v9.0.0 dereferences to. * The workflow re-triages on `reopened`. Assignment now no-ops when the item already has an assignee, so an existing owner is not swapped for whoever is on rotation the week it reopens, and no duplicate comment is posted. The check runs before the roster lookup.
1 parent fa29cdf commit a4e54ea

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

‎.github/workflows/triage.yml‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ name: Triage
1515
# a team member re-partitions future weeks. See docs/CONTRIBUTE.MD ("Triage")
1616
# for the response-time expectations that go with being on rotation.
1717
#
18+
# Both stages also run on `reopened`, so labels get refreshed on an item coming
19+
# back to life. Assignment is skipped when the item already has an assignee --
20+
# an owner from the first triage pass keeps it instead of being swapped for
21+
# whoever is on rotation the week it reopens.
22+
#
1823
# Secrets:
1924
# CODEX_AUTH_JSON Codex credentials; refreshed and written back each run.
2025
# CODEX_AUTH_STORE_TOKEN Fine-grained PAT with `secrets: write`. GITHUB_TOKEN
@@ -123,7 +128,7 @@ jobs:
123128
group: codex-auth
124129
cancel-in-progress: false
125130
steps:
126-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
131+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
127132
with:
128133
persist-credentials: false
129134

@@ -437,14 +442,33 @@ jobs:
437442
CLASSIFICATION: ${{ needs.classify.outputs.classification }}
438443
DRY_RUN: ${{ needs.preflight.outputs.dry_run }}
439444
steps:
440-
- uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9.0.0
445+
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
441446
with:
442447
# Needs `read:org` for team membership plus write on issues and pull
443448
# requests; the default GITHUB_TOKEN 403s on listMembersInOrg.
444449
github-token: ${{ secrets.ROTATION_TOKEN }}
445450
script: |
446451
const org = process.env.ROTATION_ORG;
447452
const team_slug = process.env.ROTATION_TEAM;
453+
const number = Number(process.env.TARGET_NUMBER);
454+
455+
// This workflow also runs on `reopened`, so an item may already
456+
// have been triaged. An existing assignee means a human already
457+
// owns it; re-assigning would hand it to whoever is on rotation
458+
// this week and comment a second time. Leave it alone.
459+
const { data: target } = await github.rest.issues.get({
460+
...context.repo,
461+
issue_number: number,
462+
});
463+
const existing = (target.assignees || []).map((a) => a.login);
464+
465+
if (existing.length > 0) {
466+
core.notice(
467+
`#${number} is already assigned to ${existing.join(', ')}; ` +
468+
`leaving the existing owner in place.`,
469+
);
470+
return;
471+
}
448472
449473
// Roster: team membership, sorted so week-to-week order is stable.
450474
const members = await github.paginate(
@@ -463,7 +487,6 @@ jobs:
463487
const weeks = Math.floor((Date.now() / 86400000 + 3) / 7);
464488
const onCall = roster[weeks % roster.length];
465489
466-
const number = Number(process.env.TARGET_NUMBER);
467490
const classification = process.env.CLASSIFICATION;
468491
469492
core.info(`Roster (${roster.length}): ${roster.join(', ')}`);

0 commit comments

Comments
 (0)