Skip to content

Commit

Permalink
Handle hotfix branch
Browse files Browse the repository at this point in the history
  • Loading branch information
loicgreffier committed Oct 31, 2024
1 parent 1214bb3 commit a98f6a5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Hotfix

on:
workflow_dispatch:
inputs:
tag_version:
description: 'Tag version'
required: true

jobs:
create-branch:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
token: ${{ secrets.CI_CD_TOKEN }}

- name: Create hotfix branch
run: |
START_TAG=v${{ github.event.inputs.tag_version }}
echo "Start from tag $START_TAG"
MAJOR_MINOR_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 1-2)
PATCH_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 3)
NEW_PATCH_DIGIT=$((PATCH_DIGIT + 1))
HOTFIX_VERSION="${MAJOR_MINOR_DIGIT}.${NEW_PATCH_DIGIT}"
HOTFIX_BRANCH_NAME="hotfix/$HOTFIX_VERSION"
echo "Create hotfix branch $HOTFIX_BRANCH_NAME"
git fetch --all
git checkout tags/$START_TAG -b $HOTFIX_BRANCH_NAME
git push origin $HOTFIX_BRANCH_NAME
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Pull request
name: Pull Request

on:
pull_request:
branches: [ main ]
branches:
- 'main'
- 'hotfix/v*.*.*'

jobs:
build:
Expand All @@ -23,7 +25,7 @@ jobs:
distribution: 'temurin'
cache: maven

- name: Check Style
- name: Check style
run: mvn checkstyle:check

- name: Build
Expand All @@ -32,7 +34,7 @@ jobs:
- name: Test
run: mvn test

- name: Publish Test Report
- name: Publish test report
if: always()
uses: mikepenz/action-junit-report@v4
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Continuous integration
name: Push Main

on:
push:
branches: [ main ]
branches:
- 'main'

jobs:
build:
Expand All @@ -28,7 +29,7 @@ jobs:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Check Style
- name: Check style
run: mvn checkstyle:check

- name: Build
Expand All @@ -40,7 +41,7 @@ jobs:
- name: Test
run: mvn test

- name: Publish Test Report
- name: Publish test report
if: always()
uses: mikepenz/action-junit-report@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
tag:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/v')
steps:
- name: Checkout project
uses: actions/checkout@v4
Expand Down

0 comments on commit a98f6a5

Please sign in to comment.