-
Notifications
You must be signed in to change notification settings - Fork 13
docs: stack object in pull_request webhooks #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| title: Webhooks | ||
| description: Reference for the stack object in pull_request webhook event payloads. | ||
| --- | ||
|
|
||
| When a pull request belongs to a stack, GitHub adds a `stack` property to the `pull_request` object in webhook event payloads. This lets apps and integrations inspect the stack's ultimate target branch — not just the direct parent branch of the PR. | ||
|
|
||
| The `stack` object is included in the `pull_request` webhook payload for all [pull request lifecycle events](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request). | ||
|
skarim marked this conversation as resolved.
|
||
|
|
||
|
|
||
|
|
||
| ## The `stack` Object | ||
|
|
||
| The `stack` object is nested inside the `pull_request` object and contains information about the stack's base branch: | ||
|
|
||
| ```json | ||
| { | ||
| "action": "synchronize", | ||
| "pull_request": { | ||
| "number": 42, | ||
| "title": "Add API routes", | ||
| "base": { | ||
| "ref": "feat/auth-layer", | ||
| "sha": "abc123..." | ||
| }, | ||
| "stack": { | ||
| "base": { | ||
| "ref": "main", | ||
| "sha": "def456..." | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Fields | ||
|
|
||
| | Field | Type | Description | | ||
| |-------|------|-------------| | ||
| | `pull_request.stack.base.ref` | `string` | The branch the entire stack ultimately targets (e.g., `main`). | | ||
| | `pull_request.stack.base.sha` | `string` | The HEAD SHA of that target branch at the time of the event. | | ||
|
|
||
| `pull_request.base.ref` is the direct parent branch of an individual PR (the branch below it in the stack), while `pull_request.stack.base.ref` is the ultimate target of the entire stack. These differ for all PRs in the stack except the bottom one. | ||
|
|
||
| The `stack` object is **only present** when the pull request belongs to a stack. For standalone PRs, the field is null. | ||
|
|
||
| ## GitHub Actions | ||
|
|
||
| GitHub Actions automatically evaluates workflow triggers using the stack's base branch. If a PR is part of a stack targeting `main`, any workflow configured to run on pull requests targeting `main` will run for every PR in the stack — no workflow changes are required. | ||
|
|
||
| The `stack` object is also available in GitHub Actions workflow expressions via `github.event.pull_request.stack`. See [How do I access stack metadata in my GitHub Actions workflow?](/gh-stack/faq/#how-do-i-access-stack-metadata-in-my-github-actions-workflow) in the FAQ for examples. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.