Skip to content

Commit f357a5a

Browse files
committed
feat(pr-job-rerun): add output
1 parent 39a3722 commit f357a5a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

pr/job-rerun/action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ inputs:
1818
required: false
1919
default: 'true'
2020

21+
outputs:
22+
triggered:
23+
description: 'Whether a rerun was actually triggered (true/false)'
24+
value: ${{ steps.rerun.outputs.triggered }}
25+
2126
runs:
2227
using: composite
2328
steps:
2429
- name: Rerun job(s)
30+
id: rerun
2531
uses: actions/github-script@v7
2632
with:
2733
github-token: ${{ inputs.token }}
@@ -44,12 +50,14 @@ runs:
4450
);
4551
if (activeRun) {
4652
core.info(`Workflow run ${activeRun.id} is already ${activeRun.status}, skipping rerun.`);
53+
core.setOutput('triggered', 'false');
4754
return;
4855
}
4956
5057
const completedRun = workflow_runs.find(r => r.status === 'completed');
5158
if (!completedRun) {
5259
core.warning('No workflow runs found for the current HEAD SHA.');
60+
core.setOutput('triggered', 'false');
5361
return;
5462
}
5563
@@ -61,10 +69,12 @@ runs:
6169
const job = jobs.find(j => j.name === jobName);
6270
if (!job) {
6371
core.setFailed(`Job "${jobName}" not found in run ${completedRun.id}. Available: ${jobs.map(j => j.name).join(', ')}`);
72+
core.setOutput('triggered', 'false');
6473
return;
6574
}
6675
core.info(`Rerunning job "${job.name}" (id: ${job.id}) from run ${completedRun.id}`);
6776
await github.rest.actions.reRunJobForWorkflowRun({ owner, repo, job_id: job.id });
77+
core.setOutput('triggered', 'true');
6878
return;
6979
}
7080
@@ -76,3 +86,4 @@ runs:
7686
core.info(`Rerunning all jobs for run ${completedRun.id} (conclusion: ${completedRun.conclusion})`);
7787
await github.rest.actions.reRunWorkflow({ owner, repo, run_id: completedRun.id });
7888
}
89+
core.setOutput('triggered', 'true');

0 commit comments

Comments
 (0)