Files
ToBePlayed-Core/.gitea/workflows/publish-core.yml
T
lobo 88aae0101f
Build, Test & Push Core Service / quality-check (push) Successful in 57s
Build, Test & Push Core Service / docker (push) Successful in 1m20s
feat(version): answer the build commit and time
GET /api/version is public. CI passes GIT_SHA and BUILD_TIME as Docker build args; a local build answers dev.
2026-09-27 10:27:01 +02:00

79 lines
2.6 KiB
YAML

name: Build, Test & Push Core Service
# Trigger the workflow
on:
push:
branches:
- main
jobs:
# ------------------------------------------------------------------
# JOB 1: Code integrity and quality gates (CI)
# ------------------------------------------------------------------
quality-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Java 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
# Automatically cache Maven dependencies to speed up builds
cache: 'maven'
- name: Make Maven Wrapper executable
# This fixes the "Permission denied" error on Linux runners
run: chmod +x mvnw
- name: Build and Test with Maven Wrapper
# Uses the wrapper to guarantee the correct Maven version
run: ./mvnw clean verify
# ------------------------------------------------------------------
# JOB 2: Docker Build & Push (CD)
# Runs only if 'quality-check' is successful and we are on branch main
# ------------------------------------------------------------------
docker:
needs: quality-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare tag
id: prep
shell: bash
run: |
# Sanitize branch name for valid Docker tags
BRANCH="${GITHUB_REF_NAME}"
BRANCH="${BRANCH//\//-}"
BRANCH="$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
echo "sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: git.andreas-dahm.eu
# Use your Gitea Secrets here
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN_GITEA }}
- name: Build & Push
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: |
GIT_SHA=${{ github.sha }}
BUILD_TIME=${{ steps.prep.outputs.build_time }}
tags: |
git.andreas-dahm.eu/lobo_corp/tbp-core-service:${{ steps.prep.outputs.branch }}
git.andreas-dahm.eu/lobo_corp/tbp-core-service:${{ steps.prep.outputs.branch }}-${{ steps.prep.outputs.sha }}
git.andreas-dahm.eu/lobo_corp/tbp-core-service:latest