Merge pull request #976 from peter-evans/output-sha
feat: add output for head sha
This commit is contained in:
commit
a6c8b3814a
|
@ -79,6 +79,7 @@ The following outputs can be used by subsequent workflow steps.
|
||||||
- `pull-request-number` - The pull request number.
|
- `pull-request-number` - The pull request number.
|
||||||
- `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.
|
||||||
|
|
||||||
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.
|
||||||
|
@ -215,11 +216,6 @@ jobs:
|
||||||
maintainers
|
maintainers
|
||||||
milestone: 1
|
milestone: 1
|
||||||
draft: false
|
draft: false
|
||||||
|
|
||||||
- name: Check outputs
|
|
||||||
run: |
|
|
||||||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
|
||||||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
An example based on the above reference configuration creates pull requests that look like this:
|
An example based on the above reference configuration creates pull requests that look like this:
|
||||||
|
|
1491
dist/index.js
vendored
1491
dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -110,7 +110,8 @@ export async function createOrUpdateBranch(
|
||||||
const result: CreateOrUpdateBranchResult = {
|
const result: CreateOrUpdateBranchResult = {
|
||||||
action: 'none',
|
action: 'none',
|
||||||
base: base,
|
base: base,
|
||||||
hasDiffWithBase: false
|
hasDiffWithBase: false,
|
||||||
|
headSha: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the working base changes to a temporary branch
|
// Save the working base changes to a temporary branch
|
||||||
|
@ -231,6 +232,9 @@ export async function createOrUpdateBranch(
|
||||||
result.hasDiffWithBase = await isAhead(git, base, branch)
|
result.hasDiffWithBase = await isAhead(git, base, branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the pull request branch SHA
|
||||||
|
result.headSha = await git.revParse('HEAD')
|
||||||
|
|
||||||
// Delete the temporary branch
|
// Delete the temporary branch
|
||||||
await git.exec(['branch', '--delete', '--force', tempBranch])
|
await git.exec(['branch', '--delete', '--force', tempBranch])
|
||||||
|
|
||||||
|
@ -241,4 +245,5 @@ interface CreateOrUpdateBranchResult {
|
||||||
action: string
|
action: string
|
||||||
base: string
|
base: string
|
||||||
hasDiffWithBase: boolean
|
hasDiffWithBase: boolean
|
||||||
|
headSha: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
||||||
} else if (result.action == 'updated') {
|
} else if (result.action == 'updated') {
|
||||||
core.setOutput('pull-request-operation', 'updated')
|
core.setOutput('pull-request-operation', 'updated')
|
||||||
}
|
}
|
||||||
|
core.setOutput('pull-request-head-sha', result.headSha)
|
||||||
// Deprecated
|
// Deprecated
|
||||||
core.exportVariable('PULL_REQUEST_NUMBER', pull.number)
|
core.exportVariable('PULL_REQUEST_NUMBER', pull.number)
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
Loading…
Reference in a new issue