1818 # Only run the workflow when a PR is updated or when a developer explicitly requests
1919 # a build by sending a 'firebase_build' event.
2020 pull_request :
21- types : [opened, synchronize, closed ]
21+ types : [opened, synchronize]
2222
2323 repository_dispatch :
2424 types :
2525 - firebase_build
2626
27+ # Run the release candidate action when code is pushed to dev and only if firebase.go is changed
28+ push :
29+ branches :
30+ - dev
31+ paths :
32+ - ' firebase.go'
33+
2734jobs :
2835 stage_release :
2936 # To publish a release, merge the release PR with the label 'release:publish'.
3037 # To stage a release without publishing it, send a 'firebase_build' event or apply
3138 # the 'release:stage' label to a PR.
3239 if : github.event.action == 'firebase_build' ||
3340 contains(github.event.pull_request.labels.*.name, 'release:stage') ||
34- (github.event.pull_request.merged &&
35- contains (github.event.pull_request.labels.*.name , 'release:publish '))
41+ (github.event_name == 'push' && github.ref == 'refs/heads/dev' &&
42+ startsWith (github.event.head_commit.message , '[chore] Release '))
3643
3744 runs-on : ubuntu-latest
3845
39- # When manually triggering the build, the requester can specify a target branch or a tag
40- # via the 'ref' client parameter.
4146 steps :
4247 - name : Check out code
4348 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
44- with :
45- ref : ${{ github.event.client_payload.ref || github.ref }}
4649
4750 - name : Set up Go
4851 uses : actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
@@ -65,26 +68,22 @@ jobs:
6568 publish_release :
6669 needs : stage_release
6770
68- # Check whether the release should be published. We publish only when the trigger PR is
69- # 1. merged
70- # 2. to the dev branch
71- # 3. with the label 'release:publish', and
72- # 4. the title prefix '[chore] Release '.
73- if : github.event.pull_request.merged &&
74- github.ref == 'refs/heads/dev' &&
75- contains(github.event.pull_request.labels.*.name, 'release:publish') &&
76- startsWith(github.event.pull_request.title, '[chore] Release ')
71+ # Run this ONLY when code is pushed/merged to dev
72+ # This automatically satisfies the 'Release' environment protection
73+ if : github.event_name == 'push' && github.ref == 'refs/heads/dev' &&
74+ startsWith(github.event.head_commit.message, '[chore] Release ')
7775
7876 runs-on : ubuntu-latest
7977 environment : Release
8078 permissions :
81- contents : write
79+ pull-requests : write
8280
8381 steps :
8482 - name : Checkout source for publish
8583 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
8684 with :
8785 persist-credentials : false
86+ fetch-depth : 0
8887
8988 - name : Publish preflight check
9089 id : preflight
@@ -94,10 +93,11 @@ jobs:
9493 - name : Create Release PR
9594 env :
9695 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
96+ RELEASE_BODY : ${{ steps.preflight.outputs.changelog }}
97+ RELEASE_TITLE : " [chore] Release ${{ steps.preflight.outputs.version }}"
9798 run : |
9899 gh pr create \
99100 --base master \
100101 --head dev \
101- --title "[chore] Release ${{ steps.preflight.outputs.version }}" \
102- --body "${{ steps.preflight.outputs.changelog }}" \
103- --label "release:tag"
102+ --title "$RELEASE_TITLE" \
103+ --body "$RELEASE_BODY"
0 commit comments