Skip to content

Commit ac838d7

Browse files
committed
Remove the manual dispatch trigger from the PR preview workflow
Previews are published only from the publish-preview label. The manual dispatch path checked out the pull request head in the default branch's context, which CodeQL reports as potential cache poisoning.
1 parent ac9cd46 commit ac838d7

2 files changed

Lines changed: 6 additions & 32 deletions

File tree

‎.github/workflows/pr-preview.yml‎

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,16 @@ name: Publish PR Preview
33
on:
44
pull_request:
55
types: [labeled]
6-
workflow_dispatch:
7-
inputs:
8-
pr_number:
9-
description: Pull request number to publish
10-
required: true
11-
type: string
126

137
concurrency:
14-
group: publish-pr-preview-${{ github.event.pull_request.number || github.run_id }}
8+
group: publish-pr-preview-${{ github.event.pull_request.number }}
159
cancel-in-progress: false
1610

1711
jobs:
1812
context:
1913
if: >-
20-
github.event_name == 'workflow_dispatch' ||
21-
(github.event.label.name == 'publish-preview' &&
22-
github.event.pull_request.head.repo.full_name == github.repository)
14+
github.event.label.name == 'publish-preview' &&
15+
github.event.pull_request.head.repo.full_name == github.repository
2316
runs-on: ubuntu-latest
2417
timeout-minutes: 5
2518
permissions:
@@ -33,28 +26,15 @@ jobs:
3326
id: context
3427
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
3528
env:
36-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
3729
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
38-
INPUT_PR_NUMBER: ${{ inputs.pr_number }}
39-
WORKFLOW_REF: ${{ github.ref }}
4030
with:
4131
script: |
42-
const rawPrNumber = context.eventName === 'workflow_dispatch'
43-
? process.env.INPUT_PR_NUMBER
44-
: process.env.EVENT_PR_NUMBER;
32+
const rawPrNumber = process.env.EVENT_PR_NUMBER;
4533
if (!/^[1-9][0-9]*$/.test(rawPrNumber || '')) {
4634
core.setFailed('Pull request number must contain ASCII digits only.');
4735
return;
4836
}
4937
50-
if (context.eventName === 'workflow_dispatch') {
51-
const defaultRef = `refs/heads/${process.env.DEFAULT_BRANCH}`;
52-
if (process.env.WORKFLOW_REF !== defaultRef) {
53-
core.setFailed(`Run manual previews from ${defaultRef}.`);
54-
return;
55-
}
56-
}
57-
5838
const prNumber = Number(rawPrNumber);
5939
if (!Number.isSafeInteger(prNumber)) {
6040
core.setFailed('Pull request number is outside the supported range.');

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,10 @@ that is trusted to run with the repository's publishing permissions.
3434
For a pull request from this repository, apply the `publish-preview` label. The
3535
`Publish PR Preview` workflow will build and validate a uniquely versioned
3636
`socketdev` prerelease, publish it to TestPyPI, and add or update a pull request
37-
comment with the exact version and installation command. Both label-triggered
38-
and manually dispatched previews are limited to open pull requests whose
39-
branches belong to this repository.
37+
comment with the exact version and installation command. Previews are limited
38+
to open pull requests whose branches belong to this repository.
4039

4140
The workflow reacts when the label is added; pushing another commit while the
4241
label remains on the pull request does not publish a new preview. To publish the
4342
new pull request head or retry a failed publication, remove `publish-preview`
4443
and apply it again.
45-
46-
Maintainers can also open **Actions > Publish PR Preview > Run workflow**, run
47-
it from the repository's default branch, and enter the pull request number.
48-
Manual dispatch is useful when a label should remain unchanged or a
49-
publication needs to be retried.

0 commit comments

Comments
 (0)