Skip to content

Commit 5fcc9e4

Browse files
Add input validation (branch to release num) for the release gha (#12302)
* Add input validation (branch to release num) for the release gha * Update .github/workflows/release-1-create-pr.yml Co-authored-by: valentijnscholten <valentijnscholten@gmail.com> * Update .github/workflows/release-1-create-pr.yml Co-authored-by: valentijnscholten <valentijnscholten@gmail.com> * Update .github/workflows/release-1-create-pr.yml Co-authored-by: valentijnscholten <valentijnscholten@gmail.com> * Update .github/workflows/release-1-create-pr.yml Co-authored-by: valentijnscholten <valentijnscholten@gmail.com> * Update .github/workflows/release-1-create-pr.yml Co-authored-by: valentijnscholten <valentijnscholten@gmail.com> * Resolving merge conflict --------- Co-authored-by: valentijnscholten <valentijnscholten@gmail.com>
1 parent 5635f69 commit 5fcc9e4

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

.github/workflows/release-1-create-pr.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ on:
99
# the actual branch that can be chosen on the UI is made irrelevant by further steps
1010
# because someone will forget one day to change it.
1111
from_branch:
12-
description: "Select branch to release from ('release/x.y.z'. If `dev` is entered, a new release branch will be created from `dev`)"
12+
description: "Select branch to release from. Dev branch releases happen the first monday of the month. Otherwise, use bugfix."
1313
required: true
14+
type: choice
15+
default: 'bugfix'
16+
options:
17+
- bugfix
18+
- dev
1419
release_number:
1520
description: "Release version (x.y.z format)"
1621
required: true
@@ -19,6 +24,18 @@ jobs:
1924
create_pr:
2025
runs-on: ubuntu-latest
2126
steps:
27+
- name: Validate proper bugfix branch release_number format is being used
28+
if: ${{ inputs.from_branch == 'bugfix' }}
29+
run: |
30+
# Expect the last octet in release_number to not be 0
31+
echo "${{ inputs.release_number }}" | grep "^[0-9]*\.[0-9]*\.[1-9]$"
32+
33+
- name: Validate proper dev branch release_number format is being used
34+
if: ${{ inputs.from_branch == 'dev' }}
35+
run: |
36+
# Expect the last octet in release_number to not be 1-9
37+
echo "${{ inputs.release_number }}" | grep "^[0-9]*\.[0-9]*\.0$"
38+
2239
- id: Set-GitHub-org
2340
run: echo "GITHUB_ORG=${GITHUB_REPOSITORY%%/*}" >> $GITHUB_ENV
2441

@@ -28,15 +45,9 @@ jobs:
2845
ref: ${{ github.event.inputs.from_branch }}
2946

3047
- name: Create release branch
31-
if: ${{ !startsWith(github.event.inputs.from_branch, 'release/') }}
3248
run: |
3349
echo "NEW_BRANCH=release/${{ github.event.inputs.release_number }}" >> $GITHUB_ENV
3450
35-
- name: Use existing release branch
36-
if: startsWith(github.event.inputs.from_branch, 'release/')
37-
run: |
38-
echo "NEW_BRANCH=${{ github.event.inputs.from_branch }}" >> $GITHUB_ENV
39-
4051
- name: Configure git
4152
run: |
4253
git config --global user.name "${{ env.GIT_USERNAME }}"

0 commit comments

Comments
 (0)