Skip to content

Commit

Permalink
Handle hotfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
loicgreffier committed Oct 31, 2024
1 parent 122a9a5 commit 53004df
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 28 deletions.
16 changes: 0 additions & 16 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

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
6 changes: 4 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Pull request

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

jobs:
back-end:
Expand All @@ -20,7 +22,7 @@ jobs:
distribution: 'temurin'
cache: maven

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

- name: Build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Continuous integration
name: Push Master

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

jobs:
back-end:
Expand All @@ -20,7 +21,7 @@ jobs:
distribution: 'temurin'
cache: maven

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

- name: Build
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 21
uses: actions/setup-java@v4
Expand All @@ -20,7 +22,14 @@ jobs:
cache: maven

- name: Docker
run: mvn clean package -P production jib:build -Djib.to.auth.username=$DOCKER_USER -Djib.to.auth.password=$DOCKER_TOKEN
run: |
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
LATEST_VERSION=$(git tag -l --sort=-version:refname | head -1 | cut -d 'v' -f 2)
if [ "$LATEST_VERSION" == "$CURRENT_VERSION" ]; then
mvn clean package -P production jib:build -Djib.to.auth.username=$DOCKER_USER -Djib.to.auth.password=$DOCKER_TOKEN -Djib.to.tags=latest
else
mvn clean package -P production jib:build -Djib.to.auth.username=$DOCKER_USER -Djib.to.auth.password=$DOCKER_TOKEN
fi
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
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/master'
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/hotfix/v')
steps:
- name: Checkout project
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ an Issue to discuss your proposal first. This is not required but can save time

In general, we follow the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr)

- Fork the repository to your own Github account
- Fork the repository to your own GitHub account
- Clone the project to your machine
- Create a branch locally from master with a succinct but descriptive name
- Commit changes to the branch
Expand Down
4 changes: 0 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,6 @@
</from>
<to>
<image>docker.io/michelin/${project.artifactId}:${project.version}</image>
<tags>
<tag>${project.version}</tag>
<tag>latest</tag>
</tags>
</to>
</configuration>
</plugin>
Expand Down

0 comments on commit 53004df

Please sign in to comment.