Skip to content

Commit a1dc50a

Browse files
committed
chore(actions): finalize YAML-safe contributor workflows
1 parent b751d26 commit a1dc50a

2 files changed

Lines changed: 57 additions & 34 deletions

File tree

.github/workflows/assign.yml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,15 @@ jobs:
207207
}
208208
209209
function buildQueueBody(state) {
210-
return `${QUEUE_MARKER}
211-
primary: ${state.primary || ""}
212-
primary_assigned_at: ${state.primary_assigned_at || ""}
213-
backup: ${state.backup || ""}
214-
backup_approach: ${state.backup_approach || ""}
215-
last_progress_at: ${state.last_progress_at || ""}
216-
-->`;
210+
return (
211+
`${QUEUE_MARKER}\n` +
212+
`primary: ${state.primary || ""}\n` +
213+
`primary_assigned_at: ${state.primary_assigned_at || ""}\n` +
214+
`backup: ${state.backup || ""}\n` +
215+
`backup_approach: ${state.backup_approach || ""}\n` +
216+
`last_progress_at: ${state.last_progress_at || ""}\n` +
217+
`-->`
218+
);
217219
}
218220
219221
async function ensureQueueComment() {
@@ -334,7 +336,8 @@ last_progress_at: ${state.last_progress_at || ""}
334336
} catch (e) {}
335337
336338
const forceBody =
337-
`🎯 @${targetUser} has been assigned to this issue by a maintainer. Please share meaningful progress within 3 days, or it may be opened to others.\n`;
339+
`🎯 @${targetUser} has been assigned to this issue by a maintainer. ` +
340+
`Please share meaningful progress within 3 days, or it may be opened to others.\n`;
338341
339342
await github.rest.issues.createComment({
340343
owner,
@@ -664,13 +667,15 @@ last_progress_at: ${state.last_progress_at || ""}
664667
}
665668
666669
function buildQueueBody(state) {
667-
return `${QUEUE_MARKER}
668-
primary: ${state.primary || ""}
669-
primary_assigned_at: ${state.primary_assigned_at || ""}
670-
backup: ${state.backup || ""}
671-
backup_approach: ${state.backup_approach || ""}
672-
last_progress_at: ${state.last_progress_at || ""}
673-
-->`;
670+
return (
671+
`${QUEUE_MARKER}\n` +
672+
`primary: ${state.primary || ""}\n` +
673+
`primary_assigned_at: ${state.primary_assigned_at || ""}\n` +
674+
`backup: ${state.backup || ""}\n` +
675+
`backup_approach: ${state.backup_approach || ""}\n` +
676+
`last_progress_at: ${state.last_progress_at || ""}\n` +
677+
`-->`
678+
);
674679
}
675680
676681
const now = Date.now();
@@ -688,7 +693,9 @@ last_progress_at: ${state.last_progress_at || ""}
688693
per_page: 100
689694
});
690695
691-
const queueComment = comments.find(c => String(c.body || "").includes(QUEUE_MARKER));
696+
const queueComment = comments.find(c =>
697+
String(c.body || "").includes(QUEUE_MARKER)
698+
);
692699
if (!queueComment) {
693700
continue;
694701
}

.github/workflows/stale-assignment.yml

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ jobs:
6262
}
6363
6464
function buildQueueBody(state) {
65-
return `${QUEUE_MARKER}
66-
primary: ${state.primary || ""}
67-
primary_assigned_at: ${state.primary_assigned_at || ""}
68-
backup: ${state.backup || ""}
69-
backup_approach: ${state.backup_approach || ""}
70-
last_progress_at: ${state.last_progress_at || ""}
71-
-->`;
65+
return (
66+
`${QUEUE_MARKER}\n` +
67+
`primary: ${state.primary || ""}\n` +
68+
`primary_assigned_at: ${state.primary_assigned_at || ""}\n` +
69+
`backup: ${state.backup || ""}\n` +
70+
`backup_approach: ${state.backup_approach || ""}\n` +
71+
`last_progress_at: ${state.last_progress_at || ""}\n` +
72+
`-->`
73+
);
7274
}
7375
7476
for (const issue of issues) {
@@ -94,22 +96,30 @@ last_progress_at: ${state.last_progress_at || ""}
9496
});
9597
9698
const latestAssignedEvent = events
97-
.filter(event => event.event === "assigned" && event.assignee && event.assignee.login === assignee)
99+
.filter(
100+
event =>
101+
event.event === "assigned" &&
102+
event.assignee &&
103+
event.assignee.login === assignee
104+
)
98105
.pop();
99106
100107
if (!latestAssignedEvent) {
101-
console.log(`Skipping #${issueNumber} because no matching assignment event was found.`);
108+
console.log(
109+
`Skipping #${issueNumber} because no matching assignment event was found.`
110+
);
102111
continue;
103112
}
104113
105114
const assignedAtMs = new Date(latestAssignedEvent.created_at).getTime();
106115
const elapsedMs = now - assignedAtMs;
107116
108-
const hasLinkedPR = events.some(event =>
109-
event.event === "cross-referenced" &&
110-
event.source &&
111-
event.source.issue &&
112-
event.source.issue.pull_request
117+
const hasLinkedPR = events.some(
118+
event =>
119+
event.event === "cross-referenced" &&
120+
event.source &&
121+
event.source.issue &&
122+
event.source.issue.pull_request
113123
);
114124
115125
if (hasLinkedPR) {
@@ -172,19 +182,21 @@ last_progress_at: ${state.last_progress_at || ""}
172182
queueState.backup_approach = "";
173183
queueState.last_progress_at = promotionTimeIso;
174184
185+
const queueBody = buildQueueBody(queueState);
186+
175187
if (queueComment) {
176188
await github.rest.issues.updateComment({
177189
owner,
178190
repo,
179191
comment_id: queueComment.id,
180-
body: buildQueueBody(queueState)
192+
body: queueBody
181193
});
182194
} else {
183195
await github.rest.issues.createComment({
184196
owner,
185197
repo,
186198
issue_number: issueNumber,
187-
body: buildQueueBody(queueState)
199+
body: queueBody
188200
});
189201
}
190202
@@ -213,7 +225,9 @@ last_progress_at: ${state.last_progress_at || ""}
213225
body: promotionBody
214226
});
215227
216-
console.log(`Promoted @${backup} on issue #${issueNumber} because primary @${primary} was stale.`);
228+
console.log(
229+
`Promoted @${backup} on issue #${issueNumber} because primary @${primary} was stale.`
230+
);
217231
} else {
218232
await github.rest.issues.removeAssignees({
219233
owner,
@@ -252,7 +266,9 @@ last_progress_at: ${state.last_progress_at || ""}
252266
body: unassignBody
253267
});
254268
255-
console.log(`Unassigned @${assignee} from issue #${issueNumber} (no backup claimant).`);
269+
console.log(
270+
`Unassigned @${assignee} from issue #${issueNumber} (no backup claimant).`
271+
);
256272
}
257273
258274
continue;

0 commit comments

Comments
 (0)