Skip to content

Publish on Docker & ghcr.io #285

Publish on Docker & ghcr.io

Publish on Docker & ghcr.io #285

name: Publish on Docker & ghcr.io
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
# Scheduled trigger (every day at 00:00 UTC)
schedule:
- cron: '0 0 * * *'
# On push commit trigger
push:
# branches:
# - develop
# - beta
# pull_request:
# branches:
# - develop
# - beta
# Allows manual trigger
workflow_dispatch:
# Allows external webhook trigger
repository_dispatch:
types:
- "Jellyfin Nightly Update Webhook"
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
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
# Login Docker Hub registry except on PR
# https://github.com/docker/login-action
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Login Github registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
tags: |
type=ref,event=branch
images: |
${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Extract metadata (tags, labels) for Docker (Plexdrive 5.2.1)
# https://github.com/docker/metadata-action
- name: Extract Docker metadata (Plexdrive 5.2.1)
id: meta_pd521
uses: docker/metadata-action@v5
with:
tags: |
type=ref,event=branch,suffix=-pd521
images: |
${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image (Plexdrive 5.2.1) with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image (Plexdrive 5.2.1)
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
build-args: |
PLEXDRIVE_VERSION=5.2.1
tags: ${{ steps.meta_pd521.outputs.tags }}
labels: ${{ steps.meta_pd521.outputs.labels }}