Files
XpenselyServer/.gitea/workflows/tag_release.yml
T
Cedric 6203a83af3
Build and Deploy Spring Boot Server / build (push) Successful in 1m19s
Fix Tag Workflow
2026-07-05 00:08:18 +02:00

72 lines
2.6 KiB
YAML

name: Build and Deploy Versioned Spring Boot Server
on:
push:
tags:
- "*" # Match all tags
jobs:
build:
runs-on: ubuntu-java17
steps:
# 1. Checkout the code
- name: Checkout code
uses: actions/checkout@v4
# 2. Build the Spring Boot application using the Maven wrapper
# (Java 17 is pre-installed in the runner image)
- name: Build Spring Boot Application
run: ./mvnw clean package -DskipTests
# 3. Derive version tags from the pushed git tag
# e.g. 1.1.0 -> tag_version=1.1.0, minor=1.1, major=1
- name: Extract version tags
id: ver
run: |
TAG_VERSION="${{ github.ref_name }}"
if [ -z "$TAG_VERSION" ]; then
echo "Error: TAG_VERSION is empty."
exit 1
fi
MINOR_VERSION=$(echo "$TAG_VERSION" | cut -d. -f1,2)
MAJOR_VERSION=$(echo "$TAG_VERSION" | cut -d. -f1)
echo "tag_version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
echo "minor=$MINOR_VERSION" >> "$GITHUB_OUTPUT"
echo "major=$MAJOR_VERSION" >> "$GITHUB_OUTPUT"
# 4. Set up Docker Buildx (enables layer caching)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 5. Login to Docker Hub to avoid base-image pull rate limits
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 6. Login to the Gitea registry
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: tea.zendric.de
username: ${{ secrets.TEAUSER }}
password: ${{ secrets.TEAPASSWORD }}
# 7. Build and push the versioned Docker images with layer caching.
# Pushes exact, minor, and major tags. The prod compose references
# the major tag (":1"), so pushing here makes the new build available
# to pull in Dockge — deploy is triggered MANUALLY after the DB migration.
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
tea.zendric.de/cedric/xpensely-server:${{ steps.ver.outputs.tag_version }}
tea.zendric.de/cedric/xpensely-server:${{ steps.ver.outputs.minor }}
tea.zendric.de/cedric/xpensely-server:${{ steps.ver.outputs.major }}
cache-from: type=registry,ref=tea.zendric.de/cedric/xpensely-server:buildcache
cache-to: type=registry,ref=tea.zendric.de/cedric/xpensely-server:buildcache,mode=max