64 lines
2.4 KiB
YAML
64 lines
2.4 KiB
YAML
name: Build & Push Docker Image
|
||
|
||
env:
|
||
REGISTRY: git.revwal.de
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- main
|
||
- master
|
||
tags:
|
||
- "v*"
|
||
workflow_dispatch: # allow manual runs from the Gitea UI
|
||
|
||
jobs:
|
||
build-and-push:
|
||
name: Build and push
|
||
runs-on: ubuntu-latest
|
||
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
# ── Docker setup ────────────────────────────────────────────────────────
|
||
- name: Set up Docker Buildx
|
||
uses: docker/setup-buildx-action@v3
|
||
|
||
# ── Authenticate to the Gitea container registry ────────────────────────
|
||
- name: Log in to Gitea container registry
|
||
uses: docker/login-action@v3
|
||
with:
|
||
registry: ${{ env.REGISTRY }}
|
||
username: ${{ gitea.actor }}
|
||
password: ${{ secrets.GITEATOKEN }}
|
||
|
||
# ── Tag strategy ────────────────────────────────────────────────────────
|
||
# Produces:
|
||
# • latest – on every push to the default branch
|
||
# • <branch-name> – on every push to a non-default branch
|
||
# • v1.2.3 / 1.2 – on version tags (v*)
|
||
- name: Extract Docker metadata
|
||
id: meta
|
||
uses: docker/metadata-action@v5
|
||
with:
|
||
images: ${{ env.REGISTRY }}/${{ gitea.repository }}
|
||
tags: |
|
||
type=raw,value=latest,enable={{is_default_branch}}
|
||
type=ref,event=branch
|
||
type=semver,pattern={{version}}
|
||
type=semver,pattern={{major}}.{{minor}}
|
||
|
||
# ── Build and push ───────────────────────────────────────────────────────
|
||
# Layer cache is stored in the Gitea/act_runner GHA cache so the slow
|
||
# cargo-leptos compilation is reused across runs when nothing changes.
|
||
- name: Build and push
|
||
uses: docker/build-push-action@v6
|
||
with:
|
||
context: .
|
||
push: true
|
||
tags: ${{ steps.meta.outputs.tags }}
|
||
labels: ${{ steps.meta.outputs.labels }}
|
||
cache-from: type=gha
|
||
cache-to: type=gha,mode=max
|