Update workflow to rebuild daily
All checks were successful
Build Prowlarr Container / build (push) Successful in 1m17s
All checks were successful
Build Prowlarr Container / build (push) Successful in 1m17s
This commit is contained in:
@@ -5,14 +5,22 @@ on:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
schedule:
|
||||
- cron: '0 4 * * *' # Daily at 4:00 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
# On schedule/dispatch, build both branches; otherwise only the pushed branch
|
||||
branch: ${{ github.event_name == 'schedule' && fromJson('["main", "develop"]') || fromJson(format('["{0}"]', github.ref_name)) }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ matrix.branch }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -23,25 +31,39 @@ jobs:
|
||||
# Date ISO 8601
|
||||
echo "build_date=$(date -u +%Y-%m-%dT%H:%M:%S%z)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Short SHA
|
||||
echo "sha_short=$(echo ${GITHUB_SHA} | cut -c1-7)" >> "$GITHUB_OUTPUT"
|
||||
# Short SHA of docker-prowlarr repo
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Prowlarr version from upstream API
|
||||
# Corresponding upstream Prowlarr branch
|
||||
PROWLARR_BRANCH="develop"
|
||||
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||
if [ "${{ matrix.branch }}" = "main" ]; then
|
||||
PROWLARR_BRANCH="master"
|
||||
fi
|
||||
echo "prowlarr_branch=${PROWLARR_BRANCH}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Latest commit SHA on the upstream Prowlarr repo
|
||||
UPSTREAM_SHA=$(git ls-remote https://github.com/Prowlarr/Prowlarr.git "refs/heads/${PROWLARR_BRANCH}" | awk '{print $1}')
|
||||
UPSTREAM_SHA_SHORT=$(echo "${UPSTREAM_SHA}" | cut -c1-7)
|
||||
echo "upstream_sha=${UPSTREAM_SHA}" >> "$GITHUB_OUTPUT"
|
||||
echo "upstream_sha_short=${UPSTREAM_SHA_SHORT}" >> "$GITHUB_OUTPUT"
|
||||
echo "Prowlarr upstream ${PROWLARR_BRANCH} is at ${UPSTREAM_SHA_SHORT}"
|
||||
|
||||
# Prowlarr version from upstream API
|
||||
PROWLARR_VERSION=$(curl -sL "https://prowlarr.servarr.com/v1/update/${PROWLARR_BRANCH}/changes?runtime=netcore&os=linuxmusl" | jq -r '.[0].version')
|
||||
echo "prowlarr_version=${PROWLARR_VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Image name
|
||||
REGISTRY="${{ vars.OCI_REGISTRY }}"
|
||||
# Remove trailing slash if present
|
||||
REGISTRY="${REGISTRY%/}"
|
||||
echo "image_name=${REGISTRY}/prowlarr" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Channel tag: latest for main, develop for develop
|
||||
if [ "${{ matrix.branch }}" = "main" ]; then
|
||||
echo "channel_tag=latest" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "channel_tag=develop" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Login to OCI Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
@@ -49,7 +71,23 @@ jobs:
|
||||
username: ${{ vars.OCI_USERNAME }}
|
||||
password: ${{ vars.OCI_PASSWORD }}
|
||||
|
||||
- name: Check if upstream version already built
|
||||
id: check
|
||||
if: github.event_name == 'schedule'
|
||||
run: |
|
||||
# Check if an image tagged with the upstream SHA already exists
|
||||
IMAGE="${{ steps.vars.outputs.image_name }}:${{ steps.vars.outputs.prowlarr_branch }}-${{ steps.vars.outputs.upstream_sha_short }}"
|
||||
echo "Checking if ${IMAGE} already exists..."
|
||||
if docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then
|
||||
echo "Image ${IMAGE} already exists — no upstream changes, skipping build."
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "Image ${IMAGE} not found — upstream has changed, proceeding with build."
|
||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Build and push
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
@@ -60,8 +98,9 @@ jobs:
|
||||
VERSION=${{ steps.vars.outputs.prowlarr_version }}-custom
|
||||
PROWLARR_BRANCH=${{ steps.vars.outputs.prowlarr_branch }}
|
||||
tags: |
|
||||
${{ steps.vars.outputs.image_name }}:latest
|
||||
${{ steps.vars.outputs.image_name }}:${{ steps.vars.outputs.channel_tag }}
|
||||
${{ steps.vars.outputs.image_name }}:${{ steps.vars.outputs.sha_short }}
|
||||
${{ steps.vars.outputs.image_name }}:${{ steps.vars.outputs.prowlarr_version }}-custom
|
||||
${{ steps.vars.outputs.image_name }}:${{ steps.vars.outputs.prowlarr_branch }}-${{ steps.vars.outputs.upstream_sha_short }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
Reference in New Issue
Block a user