Skip to content

Commit 1460290

Browse files
authored
Document caveat for PR event-related pipeline values
* Reorganizing content * Documenting workaround for caveat * Moving workaround * Moving workaround...for real * Making it a NOTE * Clarifying * Addressing linting error
1 parent e4da215 commit 1460290

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

docs/guides/modules/orchestrate/pages/github-trigger-event-options.adoc

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,55 @@ a| * `opened`
9191

9292
All pipelines triggered by link:https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request[pull request events] also have the following xref:reference:ROOT:variables.adoc#pipeline-values[pipeline values] populated:
9393

94-
* `pipeline.event.github.pull_request.base.ref`: the name of the *base* (or target) branch of the PR - that is the branch that will receive the changes.
95-
* `pipeline.event.github.pull_request.head.ref`: the name of the *head* branch of the PR - that is the branch containing the changes to be merged.
96-
* `pipeline.event.github.pull_request.draft`: a boolean value indicating whether the pull request is a draft.
97-
+
98-
**Example**: To trigger a pipeline on `PR opened or pushed to, default branch and tag pushes`, and ensure that it never runs if the event is associated with a draft PR, use the following:
99-
+
94+
[NOTE]
95+
====
96+
If your config contains a logical statement referencing any of the pipeline values listed below, you must do one of the following to prevent the pipeline creation from failing:
97+
98+
* Ensure your triggers only allow pull request related events.
99+
* Include a condition to ensure that the pipeline only runs for pull request related events: `pipeline.event.name == "pull_request"`.
100+
====
101+
102+
[cols=".^1,1"]
103+
|===
104+
|Pipeline value |Description
105+
106+
|`pipeline.event.github.pull_request.base.ref`
107+
|The name of the *base* (or target) branch of the PR - that is the branch that will receive the changes.
108+
109+
|`pipeline.event.github.pull_request.head.ref`
110+
|The name of the *head* branch of the PR - that is the branch containing the changes to be merged.
111+
112+
|`pipeline.event.github.pull_request.draft`
113+
|A boolean value indicating whether the pull request is a draft.
114+
115+
|`pipeline.event.github.pull_request.title`
116+
|The title of the pull request.
117+
118+
|`pipeline.event.github.pull_request.number`
119+
|The numeric identifier of the pull request.
120+
121+
|`pipeline.event.github.pull_request.merged`
122+
|A boolean that indicates whether the PR was merged or not.
123+
|===
124+
125+
These values are extracted directly from the GitHub event payload. The part after prefix `pipeline.event.github.*` matches the corresponding field in the pull request event structure described in link:https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request[the GitHub docs].
126+
127+
**Examples**:
128+
129+
If the trigger option is `PR opened or pushed to, default branch and tag pushes`, include the additional condition `pipeline.event.name == "pull_request"` to prevent the pipeline creation from failing on a `push` event:
130+
131+
[,yaml]
132+
----
133+
workflows:
134+
say-hello-workflow:
135+
when: pipeline.event.name == "pull_request" and pipeline.event.github.pull_request.number == 23
136+
jobs:
137+
- say-hello
138+
----
139+
140+
141+
To trigger a pipeline on `PR opened or pushed to, default branch and tag pushes`, and ensure that it never runs if the event is associated with a draft PR, use the following:
142+
100143
[,yaml]
101144
----
102145
workflows:
@@ -105,17 +148,10 @@ workflows:
105148
jobs:
106149
- myjob
107150
----
108-
+
109-
** The condition `pipeline.event.github.pull_request.draft == false` excludes draft PRs from triggering the workflow.
110-
** `pipeline.event.name == "api"` ensures that the workflow runs when triggered manually via the web app or API.
111-
** `pipeline.event.name == "push"` ensures that the workflow runs when triggered via push to the default branch.
112151

113-
114-
* `pipeline.event.github.pull_request.title`: the title of the pull request.
115-
* `pipeline.event.github.pull_request.number`: the numeric identifier of the pull request.
116-
* `pipeline.event.github.pull_request.merged`: a boolean that indicates whether the PR was merged or not.
117-
118-
These values are extracted directly from the GitHub event payload. The part after prefix `pipeline.event.github.*` matches the corresponding field in the pull request event structure described in link:https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request[the GitHub docs].
152+
* `pipeline.event.github.pull_request.draft == false` excludes draft PRs from triggering the workflow.
153+
* `pipeline.event.name == "api"` ensures that the workflow runs when triggered manually via the web app or API.
154+
* `pipeline.event.name == "push"` ensures that the workflow runs when triggered via push to the default branch.
119155

120156
Config orchestration tools are available from within your pipelines are as follows:
121157

0 commit comments

Comments
 (0)