60 lines
1.9 KiB
YAML
60 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 spotizerr-ui/package.json
|
|
run: |
|
|
TAG_VERSION="${{ github.ref_name }}"
|
|
VERSION="${TAG_VERSION#v}"
|
|
sed -i -E 's/"version": "[^"]+"/"version": "'"$VERSION"'"/' spotizerr-ui/package.json
|
|
|
|
# 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
|