Automatically publish container images on tag push #17

Manually merged
ansv7779 merged 1 commits from publish-container-package into main 2026-02-23 10:55:21 +01:00
3 changed files with 58 additions and 3 deletions

View File

@ -1,5 +1,7 @@
on: on:
- push push:
branches:
- '**' # do not run on tag pushes, handled by separate workflow
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -0,0 +1,54 @@
name: Publish container to package registry
on:
push:
tags:
- 'v*'
jobs:
docker-build-test-publish:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25
cache: maven
- name: Build and test with Maven
run: ./mvnw verify --batch-mode --no-transfer-progress --fail-fast
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to container registry
uses: docker/login-action@v3
with:
registry: ${{ vars.PACKAGES_REGISTRY }}
username: ${{ secrets.PACKAGES_USERNAME }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Extract version (remove leading v) and lowercase owner
id: image
run: |
TAG="${{ gitea.ref_name }}"
VERSION=${TAG#v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
OWNER=$(echo "${{ gitea.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "OWNER=${OWNER}" >> "$GITHUB_OUTPUT"
- name: Build and publish Docker image
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ vars.PACKAGES_REGISTRY }}/${{ steps.image.outputs.OWNER }}/oauth2:${{ steps.image.outputs.VERSION }}
${{ vars.PACKAGES_REGISTRY }}/${{ steps.image.outputs.OWNER }}/oauth2:latest

View File

@ -3,8 +3,7 @@
``` ```
services: services:
oauth2: oauth2:
build: https://gitea.dsv.su.se/DMC/oauth2-authorization-server.git image: gitea.dsv.su.se/dmc/oauth2:latest
restart: unless-stopped
ports: ports:
- "<host_port>:8080" - "<host_port>:8080"
environment: environment: