mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2026-02-11 16:50:16 -06:00
84 lines
2.7 KiB
YAML
84 lines
2.7 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev # Only auto-build on dev branch
|
|
tags:
|
|
- 'v*' # Still allow tagged releases
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- master
|
|
- dev
|
|
workflow_dispatch: # Allow manual triggering
|
|
inputs:
|
|
force_push:
|
|
description: 'Force push to registries (even from main branch)'
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write # Permission to write to GitHub Container Registry
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build and Push Docker Image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
huntarr/huntarr
|
|
ghcr.io/plexguide/huntarr
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,format=short
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
# Login to DockerHub
|
|
- name: Login to DockerHub
|
|
if: github.event_name != 'pull_request' && (github.ref != 'refs/heads/main' || github.event.inputs.force_push == 'true' || startsWith(github.ref, 'refs/tags/'))
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
# Login to GitHub Container Registry
|
|
- name: Login to GitHub Container Registry
|
|
if: github.event_name != 'pull_request' && (github.ref != 'refs/heads/main' || github.event.inputs.force_push == 'true' || startsWith(github.ref, 'refs/tags/'))
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Build and push to both Docker Hub and GitHub Container Registry
|
|
- name: Build and Push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
# Only push if not a PR AND (not main branch OR manual force OR tagged release)
|
|
push: ${{ github.event_name != 'pull_request' && (github.ref != 'refs/heads/main' || github.event.inputs.force_push == 'true' || startsWith(github.ref, 'refs/tags/')) }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|