|
18 | 18 | # Only run the workflow when a PR is updated or when a developer explicitly requests |
19 | 19 | # a build by sending a 'firebase_build' event. |
20 | 20 | pull_request: |
21 | | - types: [opened, synchronize] |
| 21 | + types: [opened, synchronize, closed] |
22 | 22 |
|
23 | 23 | repository_dispatch: |
24 | 24 | types: |
25 | 25 | - firebase_build |
26 | 26 |
|
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 | | - |
34 | 27 | jobs: |
35 | 28 | stage_release: |
36 | 29 | # To publish a release, merge the release PR with the label 'release:publish'. |
37 | 30 | # To stage a release without publishing it, send a 'firebase_build' event or apply |
38 | 31 | # the 'release:stage' label to a PR. |
39 | 32 | if: github.event.action == 'firebase_build' || |
40 | 33 | contains(github.event.pull_request.labels.*.name, 'release:stage') || |
41 | | - (github.event_name == 'push' && github.ref == 'refs/heads/dev' && |
42 | | - startsWith(github.event.head_commit.message, '[chore] Release ')) |
| 34 | + (github.event.pull_request.merged && |
| 35 | + contains(github.event.pull_request.labels.*.name, 'release:publish')) |
43 | 36 |
|
44 | 37 | runs-on: ubuntu-latest |
45 | 38 |
|
@@ -68,20 +61,25 @@ jobs: |
68 | 61 | publish_release: |
69 | 62 | needs: stage_release |
70 | 63 |
|
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 ') |
| 64 | + # Check whether the release should be published. We publish only when the trigger PR is |
| 65 | + # 1. merged |
| 66 | + # 2. to the dev branch |
| 67 | + # 3. with the label 'release:publish', and |
| 68 | + # 4. the title prefix '[chore] Release '. |
| 69 | + if: github.event.pull_request.merged && |
| 70 | + github.ref == 'refs/heads/dev' && |
| 71 | + contains(github.event.pull_request.labels.*.name, 'release:publish') && |
| 72 | + startsWith(github.event.pull_request.title, '[chore] Release ') |
75 | 73 |
|
76 | 74 | runs-on: ubuntu-latest |
77 | | - environment: Release |
78 | 75 | permissions: |
79 | 76 | pull-requests: write |
80 | 77 |
|
81 | 78 | steps: |
82 | 79 | - name: Checkout source for publish |
83 | 80 | uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
84 | 81 | with: |
| 82 | + ref: dev |
85 | 83 | persist-credentials: false |
86 | 84 | fetch-depth: 0 |
87 | 85 |
|
|
0 commit comments