Skip to content

Commit a9109b8

Browse files
authored
Handle hotfix branch (#281)
1 parent 530ecf6 commit a9109b8

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

.github/workflows/hotfix.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Hotfix
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_version:
7+
description: 'Tag version'
8+
required: true
9+
10+
jobs:
11+
create-branch:
12+
runs-on: ubuntu-latest
13+
if: github.ref == 'refs/heads/main'
14+
steps:
15+
- name: Checkout project
16+
uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.CI_CD_TOKEN }}
19+
20+
- name: Create hotfix branch
21+
run: |
22+
START_TAG=v${{ github.event.inputs.tag_version }}
23+
echo "Start from tag $START_TAG"
24+
MAJOR_MINOR_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 1-2)
25+
PATCH_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 3)
26+
NEW_PATCH_DIGIT=$((PATCH_DIGIT + 1))
27+
HOTFIX_VERSION="${MAJOR_MINOR_DIGIT}.${NEW_PATCH_DIGIT}"
28+
HOTFIX_BRANCH_NAME="hotfix/$HOTFIX_VERSION"
29+
echo "Create hotfix branch $HOTFIX_BRANCH_NAME"
30+
git fetch --all
31+
git checkout tags/$START_TAG -b $HOTFIX_BRANCH_NAME
32+
git push origin $HOTFIX_BRANCH_NAME
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: Pull request
1+
name: Pull Request
22

33
on:
44
pull_request:
5-
branches: [ main ]
5+
branches:
6+
- 'main'
7+
- 'hotfix/v*.*.*'
68

79
jobs:
810
build:
@@ -23,7 +25,7 @@ jobs:
2325
distribution: 'temurin'
2426
cache: maven
2527

26-
- name: Check Style
28+
- name: Check style
2729
run: mvn checkstyle:check
2830

2931
- name: Build
@@ -32,7 +34,7 @@ jobs:
3234
- name: Test
3335
run: mvn test
3436

35-
- name: Publish Test Report
37+
- name: Publish test report
3638
if: always()
3739
uses: mikepenz/action-junit-report@v4
3840
with:
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
name: Continuous integration
1+
name: Push Main
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- 'main'
67

78
jobs:
89
build:
@@ -28,7 +29,7 @@ jobs:
2829
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
2930
gpg-passphrase: MAVEN_GPG_PASSPHRASE
3031

31-
- name: Check Style
32+
- name: Check style
3233
run: mvn checkstyle:check
3334

3435
- name: Build
@@ -40,7 +41,7 @@ jobs:
4041
- name: Test
4142
run: mvn test
4243

43-
- name: Publish Test Report
44+
- name: Publish test report
4445
if: always()
4546
uses: mikepenz/action-junit-report@v4
4647
with:

.github/workflows/tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
tag:
1212
runs-on: ubuntu-latest
13-
if: github.ref == 'refs/heads/main'
13+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/v')
1414
steps:
1515
- name: Checkout project
1616
uses: actions/checkout@v4

0 commit comments

Comments
 (0)