Skip to content

Commit e1ae6f5

Browse files
committed
Harden docs preview workflows
1 parent d3b13a1 commit e1ae6f5

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

.github/workflows/CI.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ jobs:
156156
if: '!cancelled()'
157157
name: Documentation
158158
runs-on: ubuntu-latest
159-
concurrency:
160-
group: gh-pages-deploy
161-
cancel-in-progress: false
162159
steps:
163160
- uses: actions/checkout@v6
164161
- uses: julia-actions/setup-julia@v2

.github/workflows/docs-preview-cleanup.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
cleanup:
1313
name: Cleanup documentation preview
1414
runs-on: ubuntu-latest
15-
concurrency:
16-
group: gh-pages-deploy
17-
cancel-in-progress: false
1815
steps:
1916
- uses: actions/checkout@v6
2017
with:

.github/workflows/docs-preview.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ on:
1010
- master
1111

1212
permissions:
13+
actions: read
1314
issues: write
1415
pull-requests: write
1516

1617
jobs:
1718
comment:
18-
if: >-
19-
github.event.workflow_run.event == 'pull_request' &&
20-
github.event.workflow_run.conclusion == 'success'
19+
if: github.event.workflow_run.event == 'pull_request'
2120
name: Comment documentation preview URL
2221
runs-on: ubuntu-latest
2322
steps:
@@ -44,6 +43,24 @@ jobs:
4443
return;
4544
}
4645
46+
if (data.head.sha !== context.payload.workflow_run.head_sha) {
47+
core.info('Workflow run is not for the current pull request head.');
48+
return;
49+
}
50+
51+
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, {
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
run_id: context.payload.workflow_run.id,
55+
per_page: 100,
56+
});
57+
58+
const docsJob = jobs.find(job => job.name === 'Documentation');
59+
if (docsJob?.conclusion !== 'success') {
60+
core.info(`Documentation job conclusion: ${docsJob?.conclusion ?? 'missing'}.`);
61+
return;
62+
}
63+
4764
core.setOutput('number', pr.number);
4865
4966
- name: Comment preview URL

0 commit comments

Comments
 (0)