From cdf0e442779dd800ef804eb46b83ec5c097b6397 Mon Sep 17 00:00:00 2001 From: Max Starikov Date: Sat, 3 Oct 2026 19:09:51 +0200 Subject: [PATCH] fix release environment ref evaluation --- .github/workflows/create-release.yml | 6 ++++-- scripts/test_release_workflows.py | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 44a97afe..775ab28a 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -1,7 +1,9 @@ name: Create Android Release on: - pull_request: + # Use the trusted base ref so release/production environment policies evaluate + # this post-merge run as master rather than refs/pull//merge. + pull_request_target: branches: [master] types: [closed] workflow_dispatch: @@ -47,7 +49,7 @@ jobs: - name: Fetch stable history and tags run: git fetch origin master --tags - name: Require successful protected pull-request checks - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number }} diff --git a/scripts/test_release_workflows.py b/scripts/test_release_workflows.py index bd943df4..7b5d0d07 100644 --- a/scripts/test_release_workflows.py +++ b/scripts/test_release_workflows.py @@ -22,11 +22,17 @@ def test_release_pr_is_read_only_and_has_no_protected_secrets(self): def test_orchestrator_only_accepts_merged_release_candidates(self): workflow = self.read("create-release.yml") - self.assertIn("pull_request:", workflow) + self.assertIn("pull_request_target:", workflow) + self.assertNotRegex(workflow, r"(?m)^ pull_request:$") self.assertIn("types: [closed]", workflow) self.assertIn("github.event.pull_request.merged == true", workflow) self.assertIn("startsWith(github.event.pull_request.head.ref, 'release/')", workflow) self.assertIn("startsWith(github.event.pull_request.head.ref, 'hotfix/')", workflow) + self.assertIn("if: github.event_name == 'pull_request_target'", workflow) + self.assertIn( + "ref: ${{ github.event.pull_request.merge_commit_sha || inputs.commit_sha }}", + workflow, + ) self.assertIn("scripts/release_tool.py candidate", workflow) self.assertIn('gh pr checks "$PR_NUMBER" --required', workflow) self.assertIn("--check-play", workflow)