Skip to content

Commit

Permalink
feat: add branch name output (#2995)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans committed Jun 18, 2024
1 parent 4383ba9 commit c5a7806
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-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-branch` - The branch name of the pull request.

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.
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ outputs:
description: 'The pull request operation performed by the action, `created`, `updated` or `closed`.'
pull-request-head-sha:
description: 'The commit SHA of the pull request branch.'
pull-request-branch:
description: 'The pull request branch name'
runs:
using: 'node20'
main: 'dist/index.js'
Expand Down
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ function createPullRequest(inputs) {
core.setOutput('pull-request-operation', 'updated');
}
core.setOutput('pull-request-head-sha', result.headSha);
core.setOutput('pull-request-branch', inputs.branch);
// Deprecated
core.exportVariable('PULL_REQUEST_NUMBER', pull.number);
core.endGroup();
Expand Down
1 change: 1 addition & 0 deletions src/create-pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
core.setOutput('pull-request-operation', 'updated')
}
core.setOutput('pull-request-head-sha', result.headSha)
core.setOutput('pull-request-branch', inputs.branch)
// Deprecated
core.exportVariable('PULL_REQUEST_NUMBER', pull.number)
core.endGroup()
Expand Down

0 comments on commit c5a7806

Please sign in to comment.