Replace brittle inline script with Node.js script (#3619)

This commit is contained in:
Bart Louwers
2025-07-16 13:37:40 +02:00
committed by GitHub
parent 3adf431b19
commit a465aee324
6 changed files with 268 additions and 55 deletions

29
.github/scripts/check-job-skipped.ts vendored Normal file
View File

@@ -0,0 +1,29 @@
import * as core from "@actions/core";
import { Octokit } from "@octokit/rest";
async function run() {
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
const run_id = process.env.TEST_RUN_ID;
if (!run_id) throw new Error("TEST_RUN_ID not set");
const { data } = await octokit.rest.actions.listJobsForWorkflowRun({
owner: 'maplibre',
repo: 'maplibre-native',
run_id: parseInt(run_id)
});
const jobName = process.env.JOB_NAME;
if (!jobName) throw new Error("JOB_NAME not set");
const job = data.jobs.find(({name}) => name === jobName);
if (!job) throw new Error(`job with name ${jobName} not found in workflow run with id ${run_id}`);
core.setOutput('was_skipped', job.conclusion === 'skipped');
}
try {
await run();
} catch (err) {
core.setFailed(err instanceof Error ? err.message: `${err}`);
}