mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2026-01-17 18:28:04 -05:00
129 lines
4.3 KiB
YAML
129 lines
4.3 KiB
YAML
name: Docker Build and Push
|
|
on:
|
|
push:
|
|
branches:
|
|
- '*' # This will trigger on any branch push
|
|
tags:
|
|
- "*" # This will trigger on any tag push
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write # Permission to write to GitHub Container Registry
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# 1) Check out your repository code with full depth
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# 2) List files to verify huntarr.py is present
|
|
- name: List files in directory
|
|
run: ls -la
|
|
|
|
# 3) Set up QEMU for multi-architecture builds
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: arm64,amd64
|
|
|
|
# 4) Set up Docker Buildx
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
# 5a) Log in to Docker Hub
|
|
- name: Log in to Docker Hub
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
# 5b) Log in to GitHub Container Registry
|
|
- name: Log in to GitHub Container Registry
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# 6) Extract metadata (version, branch name, etc.)
|
|
- name: Extract metadata
|
|
id: meta
|
|
run: |
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
|
echo "IS_TAG=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
|
|
echo "IS_TAG=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# 7a) Build & Push if on 'main' branch (only SHA tags, no latest tag)
|
|
- name: Build and Push (main)
|
|
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
huntarr/huntarr:${{ github.sha }}
|
|
ghcr.io/plexguide/huntarr:${{ github.sha }}
|
|
|
|
# 7b) Build & Push if on 'dev' branch
|
|
- name: Build and Push (dev)
|
|
if: github.ref == 'refs/heads/dev' && github.event_name != 'pull_request'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
huntarr/huntarr:dev
|
|
huntarr/huntarr:${{ github.sha }}
|
|
ghcr.io/plexguide/huntarr:dev
|
|
ghcr.io/plexguide/huntarr:${{ github.sha }}
|
|
|
|
# 7c) Build & Push if it's a tag/release
|
|
- name: Build and Push (release)
|
|
if: steps.meta.outputs.IS_TAG == 'true' && github.event_name != 'pull_request'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
huntarr/huntarr:${{ steps.meta.outputs.VERSION }}
|
|
huntarr/huntarr:latest
|
|
ghcr.io/plexguide/huntarr:${{ steps.meta.outputs.VERSION }}
|
|
ghcr.io/plexguide/huntarr:latest
|
|
|
|
# 7d) Build & Push for any other branch
|
|
- name: Build and Push (feature branch)
|
|
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' && steps.meta.outputs.IS_TAG != 'true' && github.event_name != 'pull_request'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
huntarr/huntarr:${{ steps.meta.outputs.BRANCH }}
|
|
huntarr/huntarr:${{ github.sha }}
|
|
ghcr.io/plexguide/huntarr:${{ steps.meta.outputs.BRANCH }}
|
|
ghcr.io/plexguide/huntarr:${{ github.sha }}
|
|
|
|
# 7e) Just build on pull requests
|
|
- name: Build (PR)
|
|
if: github.event_name == 'pull_request'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
push: false
|
|
platforms: linux/amd64,linux/arm64 |