name: Build & Publish # Fork build pipeline for the "zo" forge (git.ziemlichoptimal.de/uberbau/brewlog). # On every push to `dev` this checks the code, then builds the container and # publishes it to this forge's own container registry. The moby homelab # (git.ziemlichoptimal.de/moby/cluster-moby) deploys the resulting image via # Flux GitOps — this pipeline does NOT deploy anything itself (the upstream # Fly.io deploy step was removed). on: push: branches: ["dev"] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: # This forge's built-in container registry, same host as the git server. REGISTRY: git.ziemlichoptimal.de IMAGE: git.ziemlichoptimal.de/uberbau/brewlog jobs: check: name: Check runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 # The repo's mise.toml pulls the whole dev toolchain (tailwind, cargo-watch, # flyctl, shellcheck, ...), and mise resolves most of those via the GitHub # API — which 401s on this runner (it has no github.com token), failing the # entire install. CI only needs the pinned Rust toolchain, so install it # directly via mise (rust resolves through rustup, no GitHub API). - name: Install Rust toolchain uses: https://github.com/jdx/mise-action@v2 with: install_args: rust - name: Cache Cargo artifacts uses: actions/cache@v4 with: path: | ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-check restore-keys: | cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}- cargo-${{ runner.os }}- # No sudo on the node:20-bookworm runner image (job runs as root). mold is # required by .cargo/config.toml's linker flag (-fuse-ld=mold). - name: Install system dependencies run: apt-get update && apt-get install -y --no-install-recommends clang lld mold pkg-config - name: Check formatting run: cargo fmt -- --check - name: Clippy run: cargo clippy -- -D warnings - name: Run tests run: cargo test -- --show-output build: name: Build & Publish runs-on: ubuntu-latest needs: [check] steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to the forge container registry uses: docker/login-action@v3 with: # Forgejo auto-provides GITHUB_TOKEN to the job; it can push packages # for this repo's owner (uberbau). No external registry / PAT needed. registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push container uses: docker/build-push-action@v6 with: context: . push: true # `dev` is the moving branch tag; the commit SHA is the immutable # reference. The moby Deployment pins the image by digest, so bump it # there per release (a floating tag never re-rolls the pod on its own). tags: | ${{ env.IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}:dev cache-from: type=gha cache-to: type=gha,mode=max