Skip to content

Commit 90cc582

Browse files
author
xiangying
committed
fix comments
1 parent d74f9cd commit 90cc582

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

.github/workflows/ci-pulsarbot.yaml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
- name: Execute pulsarbot command
3636
id: pulsarbot
37-
uses: actions/github-script@v7
37+
uses: actions/github-script@v8
3838
with:
3939
github-token: ${{ secrets.GITHUB_TOKEN }}
4040
script: |
@@ -61,7 +61,7 @@ jobs:
6161
const arg = parts.length > 2 ? parts.slice(2).join(' ') : '';
6262
const supported = ['rerun', 'stop', 'cancel', 'rerun-failure-checks'];
6363
if (!supported.includes(sub)) {
64-
console.log(`Unsupported command '${sub}'. Supported: '/pulsarbot rerun [jobName?]', '/pulsarbot stop', '/pulsarbot cancel'.`);
64+
console.log(`Unsupported command '${sub}'. Supported: ${supported.map(cmd => `'/pulsarbot ${cmd}'`).join(', ')}.`);
6565
return;
6666
}
6767
const prNum = context.payload.issue.number;
@@ -148,19 +148,11 @@ jobs:
148148
// Utility: rerun a single job
149149
async function rerunJob(job, run) {
150150
try {
151-
if (github.rest.actions.reRunJobForWorkflowRun) {
152-
await github.rest.actions.reRunJobForWorkflowRun({
153-
owner: context.repo.owner,
154-
repo: context.repo.repo,
155-
job_id: job.id
156-
});
157-
} else {
158-
await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', {
159-
owner: context.repo.owner,
160-
repo: context.repo.repo,
161-
job_id: job.id
162-
});
163-
}
151+
await github.rest.actions.reRunJobForWorkflowRun({
152+
owner: context.repo.owner,
153+
repo: context.repo.repo,
154+
job_id: job.id
155+
});
164156
console.log(`Re-ran job '${job.name}' (job_id=${job.id}) in run '${run.name}' | ${run.html_url}`);
165157
return true;
166158
} catch (e) {
@@ -171,10 +163,10 @@ jobs:
171163
// Command 1: /pulsarbot rerun
172164
if ((sub === 'rerun' || sub === 'rerun-failure-checks') && !arg) {
173165
const targetConclusions = new Set(['failure', 'timed_out', 'cancelled', 'skipped']);
174-
let fullRerunCount = 0;
166+
let rerunCount = 0;
175167
let skippedRunning = 0;
176168
let skippedConclusion = 0;
177-
console.log('Mode: full workflow re-run for completed runs with conclusions in [failure,timed_out,cancelled,skipped].');
169+
console.log('Mode: workflow re-run for completed runs with conclusions in [failure,timed_out,cancelled,skipped].');
178170
for (const r of latestRuns) {
179171
if (r.status !== 'completed') {
180172
console.log(`Skip (still running) ${runKey(r)}. Cannot re-run whole workflow. Consider '/pulsarbot rerun <jobName>' for single job.`);
@@ -187,21 +179,21 @@ jobs:
187179
continue;
188180
}
189181
try {
190-
await github.rest.actions.reRunWorkflow({
182+
await github.rest.actions.reRunWorkflowFailedJobs({
191183
owner: context.repo.owner,
192184
repo: context.repo.repo,
193185
run_id: r.id
194186
});
195-
console.log(`Triggered full re-run for ${runKey(r)}`);
196-
fullRerunCount++;
187+
console.log(`Triggered re-run for ${runKey(r)}`);
188+
rerunCount++;
197189
} catch (e) {
198-
console.log(`Failed to trigger full re-run for ${runKey(r)}: ${e.message}`);
190+
console.log(`Failed to trigger re-run for ${runKey(r)}: ${e.message}`);
199191
}
200192
}
201-
if (fullRerunCount === 0) {
193+
if (rerunCount === 0) {
202194
console.error(`No eligible workflow runs to re-run. Skipped running=${skippedRunning}, skipped by conclusion=${skippedConclusion}.`);
203195
} else {
204-
console.log(`Finished. Triggered full re-run for ${fullRerunCount} workflow run(s). Skipped running=${skippedRunning}, skipped by conclusion=${skippedConclusion}.`);
196+
console.log(`Finished. Triggered re-run for ${rerunCount} workflow run(s). Skipped running=${skippedRunning}, skipped by conclusion=${skippedConclusion}.`);
205197
}
206198
return;
207199
}

0 commit comments

Comments
 (0)