Skip to content

Commit 0b8e19d

Browse files
committed
refactor: avoid duplicate hardcode branch name
Signed-off-by: Adrien Mannocci <[email protected]>
1 parent 531e321 commit 0b8e19d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

.github/workflows/pre-post-release.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ on:
3636

3737
env:
3838
RELEASE_VERSION: ${{ inputs.version }}
39+
BRANCH_NAME: ${{ inputs.phase }}-release-v${{ inputs.version }}
3940

4041
permissions:
4142
contents: read
@@ -64,25 +65,25 @@ jobs:
6465

6566
- uses: actions/checkout@v4
6667
with:
67-
ref: ${{ inputs.ref || 'main' }}
68+
ref: ${{ inputs.ref }}
6869
token: ${{ env.GITHUB_TOKEN }}
6970

70-
- name: Create the release tag
71+
- name: Create the release tag (post phase)
7172
if: inputs.phase == 'post'
7273
run: |
7374
git tag "v${{ env.RELEASE_VERSION }}"
7475
git push origin "v${{ env.RELEASE_VERSION }}"
7576
7677
- name: Create a ${{ inputs.phase }} release branch
77-
run: git checkout -b ${{ inputs.phase }}-release-v${{ env.RELEASE_VERSION }}
78+
run: git checkout -b ${{ env.BRANCH_NAME }}
7879

79-
- name: Pre bump versions
80+
- name: Pre bump versions (pre phase)
8081
if: inputs.phase == 'pre'
8182
uses: ./.github/workflows/maven-goal
8283
with:
8384
command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion=${{ env.RELEASE_VERSION }}
8485

85-
- name: Post bump versions
86+
- name: Post bump versions (post phase)
8687
if: inputs.phase == 'post'
8788
uses: ./.github/workflows/maven-goal
8889
with:
@@ -92,7 +93,7 @@ jobs:
9293
run: |
9394
git add --all
9495
git commit -m "release(${{ inputs.phase }}): ecs-logging-java v${{ env.RELEASE_VERSION }}"
95-
git push origin ${{ inputs.phase }}-release-v${{ env.RELEASE_VERSION }}
96+
git push origin ${{ env.BRANCH_NAME }}
9697
9798
- name: Create the ${{ inputs.phase }} release PR
98-
run: gh pr create --title="${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}" --base main --head ${{ inputs.phase }}-release-v${{ env.RELEASE_VERSION }} -b "${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}"
99+
run: gh pr create --title="${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}" --base main --head ${{ env.BRANCH_NAME }} -b "${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}"

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
contents: write
6868
uses: ./.github/workflows/pre-post-release.yml
6969
with:
70-
ref: ${{ inputs.ref || 'main' }}
70+
ref: ${{ inputs.ref }}
7171
version: ${{ inputs.version }}
7272
phase: 'post'
7373
secrets: inherit

0 commit comments

Comments
 (0)