Skip to content

Commit b78c52a

Browse files
authored
Merge pull request #67 from github/base_ref
add new `base_ref` output
2 parents 07fa648 + 2552fc0 commit b78c52a

File tree

6 files changed

+18
-1
lines changed

6 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ As seen above, we have a single example step. Perhaps you would actually use a r
219219
| `fork_full_name` | The full name of the fork in "org/repo" format |
220220
| `sha` | The commit sha if being used in the context of a pull request |
221221
| `ref` | The ref if being used in the context of a pull request |
222+
| `base_ref` | The base ref that the pull request is merging into (if available and run in the context of a pull request) |
222223

223224
## Allowlist 👩‍🔬
224225

__tests__/schemas/action.schema.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,7 @@ outputs:
250250
description:
251251
type: string
252252
required: true
253+
base_ref:
254+
description:
255+
type: string
256+
required: true

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ outputs:
9999
description: 'The commit sha if being used in the context of a pull request'
100100
ref:
101101
description: 'The ref if being used in the context of a pull request'
102+
base_ref:
103+
description: The base ref that the pull request is merging into (if available and run in the context of a pull request)
102104
runs:
103105
using: "node20"
104106
main: "dist/index.js"

dist/index.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/prechecks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export async function prechecks(
6060
var sha = pr.data.head.sha
6161
var ref = pr.data.head.ref
6262

63+
// set an output which is the branch name this PR is targeting to merge into
64+
const baseRef = pr?.data?.base?.ref
65+
core.setOutput('base_ref', baseRef)
66+
core.debug(`base_ref: ${baseRef}`)
67+
6368
var forkBypass = false
6469

6570
// Determine whether to use the ref or sha depending on if the PR is from a fork or not

0 commit comments

Comments
 (0)