Add actions workflow for release previews

This commit is contained in:
grimsi 2025-09-03 17:44:40 +02:00
parent ee67f98431
commit 1bd48210ad
2 changed files with 54 additions and 3 deletions

View File

@ -7,16 +7,22 @@ on:
jobs:
delete-docker-tag:
if: startsWith(github.event.pull_request.head.ref, 'fix/')
if: startsWith(github.event.pull_request.head.ref, 'fix/') || startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Extract merged branch name
- name: Extract merged branch name and tag
id: extract_branch
run: |
BRANCH="${{ github.event.pull_request.head.ref }}"
TAG=${BRANCH#fix/}
if [[ "$BRANCH" == fix/* ]]; then
TAG=${BRANCH#fix/}
elif [[ "$BRANCH" == release/* ]]; then
TAG="${BRANCH#release/}-preview"
else
TAG=""
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
shell: bash

45
.github/workflows/docker-preview.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: Build and Push Docker Image (release/*)
on:
push:
branches:
- 'release/*'
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- name: Run production build
env:
GAMEYFIN_KEYSTORE_PASSWORD: ${{ secrets.GAMEYFIN_KEYSTORE_PASSWORD }}
run: ./gradlew clean build -Pvaadin.productionMode=true
- name: Extract tag from branch name
id: extract_tag
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
TAG="${BRANCH_NAME#release/}-preview"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: ./.github/actions/docker-build-push
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
ghcr_username: ${{ github.actor }}
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
context: .
dockerfile: docker/Dockerfile
platforms: linux/arm64/v8,linux/amd64
tags: grimsi/gameyfin:${{ steps.extract_tag.outputs.tag }},ghcr.io/gameyfin/gameyfin:${{ steps.extract_tag.outputs.tag }}