Skip to content

chore: Improved tooling cachability #1

chore: Improved tooling cachability

chore: Improved tooling cachability #1

Workflow file for this run

name: Docker Image
on:
push:
branches: [ main ]
paths:
- "Dockerfile"
- "docker-compose*.yaml"
- "docker-compose*.yml"
- ".dockerignore"
- "apps/app/**"
- "apps/cli/**"
- "packages/**"
- "pnpm-lock.yaml"
- "turbo.json"
tags:
- "v*"
permissions:
contents: read
packages: write
id-token: write
attestations: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish:
name: Build & Publish
runs-on: ubuntu-latest
if: github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
- target: server
image_suffix: ""
- target: cli
image_suffix: "-cli"
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}${{ matrix.image_suffix }}
docker.io/${{ secrets.DOCKERHUB_USERNAME }}/colibri${{ matrix.image_suffix }}
tags: |
# Set latest tag for main branch
type=raw,value=latest,enable={{is_default_branch}}
# Semantic versioning from git tags
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
# Branch name
type=ref,event=branch
# Short SHA
type=sha,prefix=sha-,format=short
labels: |
org.opencontainers.image.title=Colibri ${{ matrix.target == 'server' && 'Server' || 'CLI' }}
org.opencontainers.image.description=Self-hosted ebook library ${{ matrix.target == 'server' && 'web application' || 'command-line tool' }}
org.opencontainers.image.vendor=Colibri
- name: Build and push
id: push
uses: docker/build-push-action@v6
with:
context: .
target: ${{ matrix.target }}
platforms: linux/amd64,linux/arm64
push: true
annotations: ${{ steps.meta.outputs.annotations }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.target }}
cache-to: type=gha,mode=max,scope=${{ matrix.target }}
provenance: mode=max
sbom: true
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-name: ghcr.io/${{ github.repository }}${{ matrix.image_suffix }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true