mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-14 10:38:11 +02:00
70 lines
2.2 KiB
YAML
70 lines
2.2 KiB
YAML
name: Build and publish Docker image
|
|
|
|
# Builds SaraView's image (Dockerfile at the repo root) and pushes it to
|
|
# GitHub Container Registry (ghcr.io) so it can be pulled directly on
|
|
# ZimaOS instead of building locally every time.
|
|
#
|
|
# Runs on every push to main (tagged "latest" + the short commit SHA) and
|
|
# on version tags like v1.0.0 (tagged with that version). Also runnable
|
|
# by hand from the Actions tab ("workflow_dispatch").
|
|
#
|
|
# One manual, one-time step after this first runs: GHCR packages built via
|
|
# a workflow's built-in token default to PRIVATE, even on a public repo.
|
|
# Go to your GitHub profile -> Packages -> saraview -> Package settings ->
|
|
# Change visibility -> Public, or ZimaOS won't be able to pull it without
|
|
# a login.
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
tags: ["v*.*.*"]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Compute lowercase image name
|
|
# GHCR requires an all-lowercase image path even though GitHub
|
|
# usernames/repos themselves are case-insensitive (e.g. SRHTNIN
|
|
# becomes srhtnin here).
|
|
run: echo "IMAGE=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Compute tags
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.IMAGE }}
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=semver,pattern={{version}}
|
|
type=sha,prefix=,format=short
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|