Files
spotizerr-dev/.github/workflows/docker-build.yml
2025-06-03 19:39:55 -06:00

61 lines
1.9 KiB
YAML

name: Build and Push Docker Image
on:
release:
types: [ published ]
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract metadata for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: cooldockerizer93/spotizerr
# Set latest tag to follow semantic versioning
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Set 'latest' tag for the most recent semver tag (following proper semver ordering)
type=semver,pattern=latest,priority=1000
# Keep dev tag for main/master branch
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
- name: Set version in config.html
run: |
TAG_VERSION="${{ github.ref_name }}"
# Remove 'v' prefix if it exists
VERSION="${TAG_VERSION#v}"
sed -i "s|Set on build|Version: $VERSION|g" static/html/config.html
# Build and push Docker image with multiarch support
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
# Specify the multiarch platforms
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
no-cache: true