fix: semantic versionion

This commit is contained in:
u00lipp
2025-10-29 11:06:10 +01:00
parent 1cf75b58ad
commit b083163efb
+17 -4
View File
@@ -17,27 +17,38 @@ jobs:
DOCKER_IMAGE: marian.lippitz/tap-frontend
steps:
- uses: actions/checkout@v3
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch full history for branch info
- name: Validate Conventional Commits
id: validate_commits
run: |
git log -1 --pretty=%B | grep -Eq "^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\(.+\))?: .+"
shell: bash
if git log -1 --pretty=%B | grep -Eq "^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\(.+\))?: .+"; then
echo "valid=true" >> $GITHUB_ENV
else
echo "valid=false" >> $GITHUB_ENV
fi
# Only run semantic version calculation if commit message is valid
- name: Calculate Semantic Version tag
if: env.valid == 'true'
id: semver
uses: gandarez/semver-action@v2.0.0
with:
main_branch_name: main
source_branch: ${{ github.head_ref || github.ref }}
- name: Extract Variables
id: vars
if: env.valid == 'true'
run: |
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
echo "SEMVER_TAG=${{ steps.semver.outputs.semver_tag }}" >> $GITHUB_ENV
- name: Docker Login
if: env.valid == 'true'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
@@ -45,10 +56,12 @@ jobs:
echo "$DOCKER_PASSWORD" | docker login $DOCKER_REGISTRY -u "$DOCKER_USERNAME" --password-stdin
- name: Build Docker Image
if: env.valid == 'true'
run: |
docker build -t "$DOCKER_REGISTRY/$DOCKER_IMAGE:latest" -t "$DOCKER_REGISTRY/$DOCKER_IMAGE:$SEMVER_TAG" .
- name: Push Docker Images
if: env.valid == 'true'
run: |
docker push "$DOCKER_REGISTRY/$DOCKER_IMAGE:latest"
docker push "$DOCKER_REGISTRY/$DOCKER_IMAGE:$SEMVER_TAG"