diff --git a/docs/first-merged-pr-comment.md b/docs/first-merged-pr-comment.md index 706882f..f3a2ce0 100644 --- a/docs/first-merged-pr-comment.md +++ b/docs/first-merged-pr-comment.md @@ -63,12 +63,14 @@ publishing a partially rendered message. ## Repository configuration -The organization workflow template reads the optional repository variable -`FIRST_MERGED_PR_MESSAGE`. If it is absent, the installed workflow uses a -minimal generic message. - -A consumer can put its entire Markdown message in that single variable. For -example: +The organization workflow template requires the repository Actions variable +`FIRST_MERGED_PR_MESSAGE`. The workflow passes that variable directly to the +action. If it is absent or empty, the action fails instead of publishing a +fallback message. + +Configure the variable under **Settings → Secrets and variables → Actions → +Variables**. A consumer can put its entire Markdown message in that single +variable. For example: ```text Thanks {contributor_mention}! Your first pull request to {repository_name} has been merged. diff --git a/tests/test_first_merged_pr_comment_action.py b/tests/test_first_merged_pr_comment_action.py index afa40a1..f1b71cf 100644 --- a/tests/test_first_merged_pr_comment_action.py +++ b/tests/test_first_merged_pr_comment_action.py @@ -230,8 +230,15 @@ def test_workflow_template_only_exposes_message_configuration(self) -> None: workflow = ( ROOT / "workflow-templates" / "first-merged-pr-comment.yml" ).read_text(encoding="utf-8") - self.assertIn("vars.FIRST_MERGED_PR_MESSAGE", workflow) - self.assertIn("message-template:", workflow) + self.assertIn( + "message-template: ${{ vars.FIRST_MERGED_PR_MESSAGE }}", + workflow, + ) + self.assertNotIn("env:\n FIRST_MERGED_PR_MESSAGE", workflow) + self.assertNotIn( + "Thanks {contributor_mention}! Your first pull request", + workflow, + ) self.assertNotIn("survey", workflow.lower()) self.assertNotIn("community", workflow.lower()) self.assertNotIn("good first issue", workflow.lower()) diff --git a/workflow-templates/first-merged-pr-comment.yml b/workflow-templates/first-merged-pr-comment.yml index c320040..1f96633 100644 --- a/workflow-templates/first-merged-pr-comment.yml +++ b/workflow-templates/first-merged-pr-comment.yml @@ -38,11 +38,6 @@ jobs: permissions: pull-requests: write - env: - FIRST_MERGED_PR_MESSAGE: >- - ${{ vars.FIRST_MERGED_PR_MESSAGE || - 'Thanks {contributor_mention}! Your first pull request to {repository_name} has been merged.' }} - steps: # pull_request_target is intentionally used without checkout. Nothing # from the pull request head is downloaded or executed. @@ -52,4 +47,4 @@ jobs: github-token: ${{ github.token }} pull-request-number: >- ${{ github.event.pull_request.number || inputs.pull_request_number }} - message-template: ${{ env.FIRST_MERGED_PR_MESSAGE }} + message-template: ${{ vars.FIRST_MERGED_PR_MESSAGE }}