Skip to content

Commit 5ea88a3

Browse files
authored
fix: require first merged PR message variable (#178)
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 119397c commit 5ea88a3

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

‎docs/first-merged-pr-comment.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ publishing a partially rendered message.
6363

6464
## Repository configuration
6565

66-
The organization workflow template reads the optional repository variable
67-
`FIRST_MERGED_PR_MESSAGE`. If it is absent, the installed workflow uses a
68-
minimal generic message.
69-
70-
A consumer can put its entire Markdown message in that single variable. For
71-
example:
66+
The organization workflow template requires the repository Actions variable
67+
`FIRST_MERGED_PR_MESSAGE`. The workflow passes that variable directly to the
68+
action. If it is absent or empty, the action fails instead of publishing a
69+
fallback message.
70+
71+
Configure the variable under **Settings → Secrets and variables → Actions →
72+
Variables**. A consumer can put its entire Markdown message in that single
73+
variable. For example:
7274

7375
```text
7476
Thanks {contributor_mention}! Your first pull request to {repository_name} has been merged.

‎tests/test_first_merged_pr_comment_action.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,15 @@ def test_workflow_template_only_exposes_message_configuration(self) -> None:
230230
workflow = (
231231
ROOT / "workflow-templates" / "first-merged-pr-comment.yml"
232232
).read_text(encoding="utf-8")
233-
self.assertIn("vars.FIRST_MERGED_PR_MESSAGE", workflow)
234-
self.assertIn("message-template:", workflow)
233+
self.assertIn(
234+
"message-template: ${{ vars.FIRST_MERGED_PR_MESSAGE }}",
235+
workflow,
236+
)
237+
self.assertNotIn("env:\n FIRST_MERGED_PR_MESSAGE", workflow)
238+
self.assertNotIn(
239+
"Thanks {contributor_mention}! Your first pull request",
240+
workflow,
241+
)
235242
self.assertNotIn("survey", workflow.lower())
236243
self.assertNotIn("community", workflow.lower())
237244
self.assertNotIn("good first issue", workflow.lower())

‎workflow-templates/first-merged-pr-comment.yml‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ jobs:
3838
permissions:
3939
pull-requests: write
4040

41-
env:
42-
FIRST_MERGED_PR_MESSAGE: >-
43-
${{ vars.FIRST_MERGED_PR_MESSAGE ||
44-
'Thanks {contributor_mention}! Your first pull request to {repository_name} has been merged.' }}
45-
4641
steps:
4742
# pull_request_target is intentionally used without checkout. Nothing
4843
# from the pull request head is downloaded or executed.
@@ -52,4 +47,4 @@ jobs:
5247
github-token: ${{ github.token }}
5348
pull-request-number: >-
5449
${{ github.event.pull_request.number || inputs.pull_request_number }}
55-
message-template: ${{ env.FIRST_MERGED_PR_MESSAGE }}
50+
message-template: ${{ vars.FIRST_MERGED_PR_MESSAGE }}

0 commit comments

Comments
 (0)