chore: require pr number as input when manually invoking pkg.pr.new (#17797)

pull/17786/head
Elliott Johnson 2 months ago committed by GitHub
parent 673a1ab964
commit f6e8b1d11e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,6 +10,10 @@ on:
description: 'Commit SHA to build'
required: true
type: string
pr:
description: 'PR number to comment on'
required: true
type: number
permissions: {}
@ -127,26 +131,16 @@ jobs:
return;
}
const { data: pulls } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: '${{ inputs.sha }}',
});
const open = pulls.filter(p => p.state === 'open');
if (open.length === 0) {
core.setFailed(`No open PR found for commit ${{ inputs.sha }}`);
return;
}
if (open.length > 1) {
const nums = open.map(p => `#${p.number}`).join(', ');
core.setFailed(`Multiple open PRs found for commit ${{ inputs.sha }}: ${nums}`);
// For workflow_dispatch, use the explicitly provided PR number.
// We can't use listPullRequestsAssociatedWithCommit because fork
// commits don't exist in the base repo, so the API returns nothing.
const pr = Number('${{ inputs.pr }}');
if (!pr || isNaN(pr)) {
core.setFailed('workflow_dispatch requires a valid pr input');
return;
}
core.setOutput('number', open[0].number);
core.setOutput('number', pr);
- name: Post or update comment
uses: actions/github-script@v8

Loading…
Cancel
Save