mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
143 lines
4.4 KiB
YAML
143 lines
4.4 KiB
YAML
name: Build & Push Docker
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
release:
|
|
types: [created]
|
|
push:
|
|
tags:
|
|
- v[0-9]+.[0-9]+.[0-9]+*
|
|
# schedule:
|
|
# - cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime
|
|
|
|
jobs:
|
|
typecheck:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Latest Corepack
|
|
run: |
|
|
npm install -g corepack@latest
|
|
corepack enable && corepack enable pnpm
|
|
pnpm --version
|
|
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22.13.0
|
|
cache: "pnpm"
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Build server
|
|
run: pnpm turbo typecheck --filter=@tunarr/server
|
|
|
|
- name: Build web
|
|
run: pnpm turbo build --filter=@tunarr/web
|
|
|
|
build_and_push:
|
|
needs: typecheck
|
|
runs-on: ${{ matrix.builds.os }}
|
|
continue-on-error: true
|
|
strategy:
|
|
max-parallel: 2
|
|
matrix:
|
|
builds:
|
|
- base_tag: "7.1.1"
|
|
platform: linux/amd64
|
|
suffix: ""
|
|
target: linux-x64
|
|
os: ubuntu-latest
|
|
|
|
- base_tag: "7.1.1"
|
|
platform: linux/arm64
|
|
suffix: -arm64
|
|
target: linux-arm64
|
|
os: ubuntu-24.04-arm
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
flavor: |
|
|
suffix=${{ matrix.builds.suffix }},onlatest=true
|
|
images: |
|
|
chrisbenincasa/tunarr
|
|
ghcr.io/chrisbenincasa/tunarr
|
|
tags: |
|
|
# Update edge tag on the scheduled build
|
|
type=schedule,pattern=edge
|
|
# Update version tags on proper releases
|
|
type=semver,pattern={{version}}
|
|
# Update edge tag when we manually trigger the release
|
|
type=raw,value=edge,enable=${{github.ref == format('refs/heads/{0}', 'dev') && github.event_name == 'workflow_dispatch'}}
|
|
# Update alpha "latest" on any alpha release.
|
|
type=raw,value=alpha,enable=${{ contains(github.ref_name, '-alpha') }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to Github Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: actions/cache@v4 # Cache previous HEAD SHA
|
|
with:
|
|
path: previous_head_sha
|
|
key: ${{ runner.os }}-edge-build-${{ github.sha }}
|
|
restore-keys: | # Check for previous SHA in cache
|
|
${{ runner.os }}-edge-build-
|
|
|
|
- name: Check for HEAD commit changes
|
|
run: |
|
|
git fetch origin main
|
|
HEAD_SHA=$(git rev-parse HEAD)
|
|
|
|
if [[ -z "$PREVIOUS_HEAD_SHA" ]]; then
|
|
echo "No previous HEAD SHA found (first run). Building image."
|
|
elif [[ "$HEAD_SHA" != "$PREVIOUS_HEAD_SHA" ]]; then
|
|
echo "Head commit has changed. Building and pushing image."
|
|
else
|
|
echo "Head commit hasn't changed. Skipping build."
|
|
exit 0 # Exit without pushing the image
|
|
fi
|
|
echo "PREVIOUS_HEAD_SHA=$HEAD_SHA" >> previous_head_sha # Save current SHA for next run
|
|
if: github.event_name == 'schedule'
|
|
|
|
- name: Generate Version Number
|
|
run: |
|
|
echo "TUNARR_VERSION=${{github.ref_name}}" >> $GITHUB_ENV
|
|
echo "TUNARR_BUILD=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: ${{matrix.builds.platform}}
|
|
build-args: |
|
|
base_image_tag=${{ matrix.builds.base_tag }}
|
|
is_edge_build=${{github.ref == format('refs/heads/{0}', 'dev') && github.event_name == 'schedule'}}
|
|
tunarr_version=${{ env.TUNARR_VERSION }}
|
|
tunarr_build=${{ env.TUNARR_BUILD }}
|
|
exec_target=${{ matrix.builds.target }}
|
|
target: full-stack
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|