@@ -58,11 +58,15 @@ inputs:
58
58
Branch to open pull release PR against. Defaults to the repository's
59
59
default branch.
60
60
default : " "
61
- maintenance -branch-pattern :
61
+ target -branch-pattern :
62
62
description : >-
63
- Regex pattern for maintenance branches. Defaults to `^release-[0-9]+(\.[0-9]+)?\.x$`.
64
- default : |-
65
- ^release-[0-9]+(\.[0-9]+)?\.x$
63
+ Regular expression pattern to determine if current branch is a target
64
+ branch. When specified, the action will only run if the current branch
65
+ matches the pattern, and the current branch will be used as the target
66
+ branch. When not specified, the action will always run, and target the
67
+ specified target-branch, or the repository's default branch if
68
+ target-branch is not specified.
69
+ default : " "
66
70
config-file :
67
71
description : Path to config file within the project.
68
72
default : " .github/release-please-config.json"
@@ -138,8 +142,26 @@ outputs:
138
142
runs :
139
143
using : " composite"
140
144
steps :
145
+ - name : prepare
146
+ shell : bash
147
+ id : prepare
148
+ run : |
149
+ if [[ -n "$TARGET_BRANCH_PATTERN" ]]; then
150
+ if [[ "$GITHUB_REF_NAME" =~ $TARGET_BRANCH_PATTERN ]]; then
151
+ RUN="true"
152
+ TARGET="$GITHUB_REF_NAME"
153
+ fi
154
+ else
155
+ RUN="true"
156
+ fi
157
+
158
+ echo "target_branch=${TARGET:-$TARGET_BRANCH}" >> "$GITHUB_OUTPUT"
159
+ echo "run=${RUN:-false}" >> "$GITHUB_OUTPUT"
160
+ env :
161
+ TARGET_BRANCH : " ${{ inputs.target-branch }}"
162
+ TARGET_BRANCH_PATTERN : " ${{ inputs.target-branch-pattern }}"
141
163
- uses : tibdex/github-app-token@v2
142
- if : inputs.app-id != null && inputs.app-id != ''
164
+ if : steps.prepare.outputs.run == 'true' && inputs.app-id != null && inputs.app-id != ''
143
165
id : github-app-token
144
166
with :
145
167
app_id : ${{ inputs.app-id }}
@@ -151,27 +173,20 @@ runs:
151
173
repositories : ${{ inputs.repositories }}
152
174
revoke : true
153
175
- name : resolve token
176
+ if : steps.prepare.outputs.run == 'true'
154
177
id : token
178
+ shell : bash
155
179
run : |-
156
180
echo "token=${APP_TOKEN:-$INPUT_TOKEN}" >> "$GITHUB_OUTPUT"
157
181
env :
158
182
APP_TOKEN : " ${{ steps.github-app-token.outputs.token }}"
159
183
INPUT_TOKEN : " ${{ inputs.token }}"
160
- shell : bash
161
- - name : determine target-branch
162
- id : branch
163
- run : |
164
- if [[ -z "${{ inputs.target-branch }}" ]] && [[ "${{ github.ref_name }}" =~ ${{ inputs.maintenance-branch-pattern }} ]]; then
165
- echo "target_branch=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
166
- else
167
- echo "target_branch=${{ inputs.target-branch }}" >> "$GITHUB_OUTPUT"
168
- fi
169
- shell : bash
170
184
- uses : googleapis/release-please-action@v4
185
+ if : steps.prepare.outputs.run == 'true'
171
186
id : release-please
172
187
with :
173
188
token : ${{ steps.token.outputs.token }}
174
- target-branch : ${{ steps.branch .outputs.target_branch }}
189
+ target-branch : ${{ steps.prepare .outputs.target_branch }}
175
190
config-file : ${{ inputs.config-file }}
176
191
manifest-file : ${{ inputs.manifest-file }}
177
192
github-api-url : ${{ inputs.github-api-url }}
0 commit comments