Skip to content

Commit 4c0ec62

Browse files
authored
Use check-job-skipped.ts in other workflows (maplibre#3653)
1 parent 173ecdb commit 4c0ec62

4 files changed

Lines changed: 37 additions & 18 deletions

File tree

.github/scripts/check-job-skipped.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async function run() {
2020
if (!job) throw new Error(`job with name ${jobName} not found in workflow run with id ${run_id}`);
2121

2222
core.setOutput('was_skipped', job.conclusion === 'skipped');
23+
core.setOutput('was_skipped_or_cancelled', job.conclusion === 'skipped' || job.conclusion === 'cancelled');
2324
}
2425

2526
try {

.github/workflows/pr-bloaty-ios.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ jobs:
1717
if: github.event.workflow_run.event == 'pull_request'
1818
runs-on: ubuntu-latest
1919
outputs:
20-
should_skip: ${{ steps.check_skip.outputs.should_skip }}
20+
should_skip: ${{ steps.parent_workflow.outputs.was_skipped_or_cancelled }}
2121
steps:
22-
- id: check_skip
23-
run: |
24-
conclusion=$(curl --retry 12 --retry-all-errors ${{ github.event.workflow_run.jobs_url }} | jq -r '.jobs[] | select(.name == "ios-build").conclusion')
25-
should_skip=$([[ "$conclusion" = "skipped" || "$conclusion" = "cancelled" ]] && echo "true" || echo "false")
26-
echo "should_skip=$should_skip" >> "$GITHUB_OUTPUT"
22+
- uses: actions/checkout@v4
23+
with:
24+
sparse-checkout: .github
25+
26+
- name: Get parent workflow result
27+
id: parent_workflow
28+
run: node .github/scripts/check-job-skipped.ts
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
TEST_RUN_ID: ${{ github.event.workflow_run.id }}
32+
JOB_NAME: ios-build
2733

2834
pr-bloaty-ios:
2935
needs: pre_job

.github/workflows/pr-linux-tests.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ jobs:
2020
if: github.event.workflow_run.event == 'pull_request'
2121
runs-on: ubuntu-latest
2222
outputs:
23-
should_skip: ${{ steps.check_skip.outputs.should_skip }}
23+
should_skip: ${{ steps.parent_workflow.outputs.was_skipped_or_cancelled }}
2424
steps:
25-
- id: check_skip
26-
run: |
27-
conclusion=$(curl --retry 12 --retry-all-errors ${{ github.event.workflow_run.jobs_url }} | jq -r '.jobs[] | select(.name == "linux-build-and-test").conclusion')
28-
should_skip=$([[ "$conclusion" = "skipped" || "$conclusion" = "cancelled" ]] && echo "true" || echo "false")
29-
echo "should_skip=$should_skip" >> "$GITHUB_OUTPUT"
25+
- uses: actions/checkout@v4
26+
with:
27+
sparse-checkout: .github
28+
29+
- name: Get parent workflow result
30+
id: parent_workflow
31+
run: node .github/scripts/check-job-skipped.ts
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
TEST_RUN_ID: ${{ github.event.workflow_run.id }}
35+
JOB_NAME: linux-build-and-test
3036

3137
pr-bloaty:
3238
needs: pre_job

.github/workflows/upload-coverage.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ jobs:
1010
pre_job:
1111
runs-on: ubuntu-latest
1212
outputs:
13-
should_run: ${{ steps.check_skip.outputs.should_run }}
13+
should_run: ${{ !steps.parent_workflow.outputs.was_skipped_or_cancelled }}
1414
steps:
15-
- id: check_skip
16-
run: |
17-
conclusion=$(curl --retry 12 --retry-all-errors ${{ github.event.workflow_run.jobs_url }} | jq -r '.jobs[] | select(.name == "linux-coverage").conclusion')
18-
should_run=$([[ "$conclusion" = "success" ]] && echo "true" || echo "false")
19-
echo "should_run=$should_run" >> "$GITHUB_OUTPUT"
15+
- uses: actions/checkout@v4
16+
with:
17+
sparse-checkout: .github
18+
19+
- name: Get parent workflow result
20+
id: parent_workflow
21+
run: node .github/scripts/check-job-skipped.ts
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
TEST_RUN_ID: ${{ github.event.workflow_run.id }}
25+
JOB_NAME: linux-coverage
2026

2127
upload-coverage:
2228
needs: pre_job

0 commit comments

Comments
 (0)