Replace brittle inline script with Node.js script (#3619)
This commit is contained in:
29
.github/scripts/check-job-skipped.ts
vendored
Normal file
29
.github/scripts/check-job-skipped.ts
vendored
Normal 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}`);
|
||||
}
|
||||
12
.github/workflows/android-device-test.yml
vendored
12
.github/workflows/android-device-test.yml
vendored
@@ -84,11 +84,13 @@ jobs:
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- id: parent_workflow
|
||||
run: |
|
||||
conclusion=$(curl --retry 12 --retry-all-errors ${{ github.event.workflow_run.jobs_url }} | jq -r '.jobs[] | select(.name == "android-build").conclusion')
|
||||
was_skipped=$([[ "$conclusion" = "skipped" || "$conclusion" = "cancelled" ]] && echo "true" || echo "false")
|
||||
echo "was_skipped=$was_skipped" >> "$GITHUB_OUTPUT"
|
||||
- name: Check if android-build was skipped
|
||||
id: parent_workflow
|
||||
run: node .github/scripts/check-job-skipped.ts
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TEST_RUN_ID: ${{ github.event.workflow_run.jobs_url }}
|
||||
JOB_NAME: android-build
|
||||
|
||||
# get comment from PR
|
||||
|
||||
|
||||
2
.github/workflows/typecheck-scripts.yml
vendored
2
.github/workflows/typecheck-scripts.yml
vendored
@@ -13,4 +13,4 @@ jobs:
|
||||
|
||||
- run: |
|
||||
npm install
|
||||
npx tsc -p scripts/jsconfig.json
|
||||
npx tsc -p tsconfig.json
|
||||
|
||||
Reference in New Issue
Block a user