Skip to content

Commit 35832e9

Browse files
committed
ci: retry Day 2 release step on transient action download failures
1 parent 22262fc commit 35832e9

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

‎.github/workflows/day2-release.yml‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,87 @@ jobs:
1616
if: vars.CLASSROOM_DAY2_ASSIGNMENT_URL != ''
1717
steps:
1818
- name: Evaluate Day 1 completion signals and release Day 2 link
19+
id: day2_release_primary
20+
continue-on-error: true
21+
uses: actions/github-script@v7
22+
env:
23+
DAY2_ASSIGNMENT_URL: ${{ vars.CLASSROOM_DAY2_ASSIGNMENT_URL }}
24+
with:
25+
script: |
26+
const day2Url = (process.env.DAY2_ASSIGNMENT_URL || '').trim();
27+
28+
if (!day2Url) {
29+
core.info('Missing required configuration for Day 2 release gate.');
30+
return;
31+
}
32+
33+
const enrollmentIssues = await github.paginate(github.rest.issues.listForRepo, {
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
labels: 'classroom-enrollment,enrolled',
37+
state: 'all',
38+
per_page: 100
39+
});
40+
41+
for (const enrollment of enrollmentIssues) {
42+
const alreadyReleased = enrollment.labels.some(l => l.name === 'day2-released');
43+
if (alreadyReleased) {
44+
continue;
45+
}
46+
47+
const student = enrollment.user.login;
48+
const hasEligibilityLabel = enrollment.labels.some(l => l.name === 'day2-eligible' || l.name === 'day1-complete');
49+
50+
const comments = await github.paginate(github.rest.issues.listComments, {
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
issue_number: enrollment.number,
54+
per_page: 100
55+
});
56+
57+
const hasCompletionComment = comments.some(c =>
58+
(c.user?.login || '').toLowerCase() === student.toLowerCase() &&
59+
/\bday\s*1\s*complete\b|\bday1-complete\b/i.test(c.body || '')
60+
);
61+
62+
if (!hasEligibilityLabel && !hasCompletionComment) {
63+
continue;
64+
}
65+
66+
const hasReleaseComment = comments.some(c => (c.body || '').includes('<!-- day2-release-bot -->'));
67+
if (!hasReleaseComment) {
68+
const body = [
69+
'<!-- day2-release-bot -->',
70+
'## Day 2 is unlocked',
71+
'',
72+
`Hi @${student}, your Day 1 completion was confirmed.`,
73+
'',
74+
`- Day 2 assignment: ${day2Url}`,
75+
'',
76+
'If you do not see this in GitHub notifications, check your email notifications for this issue thread.'
77+
].join('\n');
78+
79+
await github.rest.issues.createComment({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
issue_number: enrollment.number,
83+
body
84+
});
85+
}
86+
87+
const labelsToAdd = ['day2-eligible', 'day2-released'];
88+
await github.rest.issues.addLabels({
89+
owner: context.repo.owner,
90+
repo: context.repo.repo,
91+
issue_number: enrollment.number,
92+
labels: labelsToAdd
93+
});
94+
95+
core.info(`Released Day 2 for @${student}.`);
96+
}
97+
98+
- name: Retry Day 2 release once if primary step failed
99+
if: ${{ steps.day2_release_primary.outcome == 'failure' }}
19100
uses: actions/github-script@v7
20101
env:
21102
DAY2_ASSIGNMENT_URL: ${{ vars.CLASSROOM_DAY2_ASSIGNMENT_URL }}

0 commit comments

Comments
 (0)