feat: add branch name output (#2995)

This commit is contained in:
Peter Evans 2024-06-18 09:51:55 -07:00 committed by GitHub
parent 4383ba9ef0
commit c5a7806660
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 5 additions and 0 deletions

View file

@ -117,6 +117,7 @@ The following outputs can be used by subsequent workflow steps.
- `pull-request-url` - The URL of the pull request. - `pull-request-url` - The URL of the pull request.
- `pull-request-operation` - The pull request operation performed by the action, `created`, `updated` or `closed`. - `pull-request-operation` - The pull request operation performed by the action, `created`, `updated` or `closed`.
- `pull-request-head-sha` - The commit SHA of the pull request branch. - `pull-request-head-sha` - The commit SHA of the pull request branch.
- `pull-request-branch` - The branch name of the pull request.
Step outputs can be accessed as in the following example. Step outputs can be accessed as in the following example.
Note that in order to read the step outputs the action step must have an id. Note that in order to read the step outputs the action step must have an id.

View file

@ -83,6 +83,8 @@ outputs:
description: 'The pull request operation performed by the action, `created`, `updated` or `closed`.' description: 'The pull request operation performed by the action, `created`, `updated` or `closed`.'
pull-request-head-sha: pull-request-head-sha:
description: 'The commit SHA of the pull request branch.' description: 'The commit SHA of the pull request branch.'
pull-request-branch:
description: 'The pull request branch name'
runs: runs:
using: 'node20' using: 'node20'
main: 'dist/index.js' main: 'dist/index.js'

1
dist/index.js vendored
View file

@ -458,6 +458,7 @@ function createPullRequest(inputs) {
core.setOutput('pull-request-operation', 'updated'); core.setOutput('pull-request-operation', 'updated');
} }
core.setOutput('pull-request-head-sha', result.headSha); core.setOutput('pull-request-head-sha', result.headSha);
core.setOutput('pull-request-branch', inputs.branch);
// Deprecated // Deprecated
core.exportVariable('PULL_REQUEST_NUMBER', pull.number); core.exportVariable('PULL_REQUEST_NUMBER', pull.number);
core.endGroup(); core.endGroup();

View file

@ -223,6 +223,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
core.setOutput('pull-request-operation', 'updated') core.setOutput('pull-request-operation', 'updated')
} }
core.setOutput('pull-request-head-sha', result.headSha) core.setOutput('pull-request-head-sha', result.headSha)
core.setOutput('pull-request-branch', inputs.branch)
// Deprecated // Deprecated
core.exportVariable('PULL_REQUEST_NUMBER', pull.number) core.exportVariable('PULL_REQUEST_NUMBER', pull.number)
core.endGroup() core.endGroup()