Skip to content

Commit 60cd33a

Browse files
committed
clean up webhooks content
1 parent c287587 commit 60cd33a

4 files changed

Lines changed: 81 additions & 166 deletions

File tree

docs/astro.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ export default defineConfig({
6565
{ label: 'Working with Stacked PRs', slug: 'guides/stacked-prs' },
6666
{ label: 'Stacked PRs in the GitHub UI', slug: 'guides/ui' },
6767
{ label: 'Typical Workflows', slug: 'guides/workflows' },
68-
{ label: 'CI and Custom Integrations', slug: 'guides/ci-integration' },
6968
],
7069
},
7170
{
7271
label: 'Reference',
7372
items: [
7473
{ label: 'CLI Commands', slug: 'reference/cli' },
74+
{ label: 'Webhooks', slug: 'reference/webhooks' },
7575
],
7676
},
7777
{

docs/src/content/docs/faq.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,35 @@ Every PR in a stack is treated as if it is targeting the **base of the stack** (
7171

7272
GitHub Actions workflows trigger as if each PR in the stack is targeting the base of the stack (e.g., `main`). If you have a workflow configured to run on `pull_request` events targeting `main`, it will run for **every PR in the stack** — not just the bottom one.
7373

74+
### How do I access stack metadata in my GitHub Actions workflow?
75+
76+
For advanced use cases, you can access the stack's base ref and base SHA in workflow expressions via `github.event.pull_request.stack`. This property is only present when the PR belongs to a stack.
77+
78+
```yaml
79+
jobs:
80+
build:
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v4
84+
85+
- name: Show stack info
86+
if: github.event.pull_request.stack != null
87+
run: |
88+
echo "Stack base ref: ${{ github.event.pull_request.stack.base.ref }}"
89+
echo "Stack base SHA: ${{ github.event.pull_request.stack.base.sha }}"
90+
91+
- name: Run a step only when the stack targets a release branch
92+
if: startsWith(github.event.pull_request.stack.base.ref, 'release/')
93+
run: echo "This stack targets a release branch"
94+
```
95+
96+
| Expression | Description |
97+
|------------|-------------|
98+
| `github.event.pull_request.stack.base.ref` | The branch the entire stack ultimately targets (e.g., `main`). |
99+
| `github.event.pull_request.stack.base.sha` | The HEAD SHA of that target branch at the time of the event. |
100+
101+
See the [Webhooks reference](/gh-stack/reference/webhooks/) for the full details on the `stack` object in webhook payloads.
102+
74103
### Do all previous PRs need to be passing checks before I can merge?
75104

76105
Yes. In order to merge a PR in the stack, **all PRs below it** must also have passing checks and meet all merge requirements. For example, in a stack of `main <- PR1 <- PR2 <- PR3`, if you want to merge PR #3, both PR #1 and PR #2 must have passing checks, required reviews, and satisfy all branch protection rules.

docs/src/content/docs/guides/ci-integration.md

Lines changed: 0 additions & 165 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Webhooks
3+
description: Reference for the stack object in pull_request webhook event payloads.
4+
---
5+
6+
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.
7+
8+
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).
9+
10+
11+
12+
## The `stack` Object
13+
14+
The `stack` object is nested inside the `pull_request` object and contains information about the stack's base branch:
15+
16+
```json
17+
{
18+
"action": "synchronize",
19+
"pull_request": {
20+
"number": 42,
21+
"title": "Add API routes",
22+
"base": {
23+
"ref": "feat/auth-layer",
24+
"sha": "abc123..."
25+
},
26+
"stack": {
27+
"base": {
28+
"ref": "main",
29+
"sha": "def456..."
30+
}
31+
}
32+
}
33+
}
34+
```
35+
36+
### Fields
37+
38+
| Field | Type | Description |
39+
|-------|------|-------------|
40+
| `pull_request.stack.base.ref` | `string` | The branch the entire stack ultimately targets (e.g., `main`). |
41+
| `pull_request.stack.base.sha` | `string` | The HEAD SHA of that target branch at the time of the event. |
42+
43+
`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.
44+
45+
The `stack` object is **only present** when the pull request belongs to a stack. For standalone PRs, the field is null.
46+
47+
## GitHub Actions
48+
49+
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.
50+
51+
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.

0 commit comments

Comments
 (0)