Skip to content

Commit cdf0e44

Browse files
committed
fix release environment ref evaluation
1 parent 479bea6 commit cdf0e44

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎.github/workflows/create-release.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Create Android Release
22

33
on:
4-
pull_request:
4+
# Use the trusted base ref so release/production environment policies evaluate
5+
# this post-merge run as master rather than refs/pull/<number>/merge.
6+
pull_request_target:
57
branches: [master]
68
types: [closed]
79
workflow_dispatch:
@@ -47,7 +49,7 @@ jobs:
4749
- name: Fetch stable history and tags
4850
run: git fetch origin master --tags
4951
- name: Require successful protected pull-request checks
50-
if: github.event_name == 'pull_request'
52+
if: github.event_name == 'pull_request_target'
5153
env:
5254
GH_TOKEN: ${{ github.token }}
5355
PR_NUMBER: ${{ github.event.pull_request.number }}

‎scripts/test_release_workflows.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ def test_release_pr_is_read_only_and_has_no_protected_secrets(self):
2222

2323
def test_orchestrator_only_accepts_merged_release_candidates(self):
2424
workflow = self.read("create-release.yml")
25-
self.assertIn("pull_request:", workflow)
25+
self.assertIn("pull_request_target:", workflow)
26+
self.assertNotRegex(workflow, r"(?m)^ pull_request:$")
2627
self.assertIn("types: [closed]", workflow)
2728
self.assertIn("github.event.pull_request.merged == true", workflow)
2829
self.assertIn("startsWith(github.event.pull_request.head.ref, 'release/')", workflow)
2930
self.assertIn("startsWith(github.event.pull_request.head.ref, 'hotfix/')", workflow)
31+
self.assertIn("if: github.event_name == 'pull_request_target'", workflow)
32+
self.assertIn(
33+
"ref: ${{ github.event.pull_request.merge_commit_sha || inputs.commit_sha }}",
34+
workflow,
35+
)
3036
self.assertIn("scripts/release_tool.py candidate", workflow)
3137
self.assertIn('gh pr checks "$PR_NUMBER" --required', workflow)
3238
self.assertIn("--check-play", workflow)

0 commit comments

Comments
 (0)