Skip to content

refactor: critique fixes for discover empty state, stale docs, silent… #102

refactor: critique fixes for discover empty state, stale docs, silent…

refactor: critique fixes for discover empty state, stale docs, silent… #102

Workflow file for this run

name: Build image
on:
push:
branches: [ "main" ]
paths:
- "api/**"
- "web/**"
- "Dockerfile"
- ".dockerignore"
- ".github/workflows/build.yml"
workflow_dispatch:
inputs:
version:
description: "Existing release version to (re)build and publish (e.g. 0.15.0). Empty = build main as :latest only."
required: false
type: string
default: ""
workflow_call:
inputs:
version:
description: "Release version to tag the image with (e.g. 0.0.1). Empty = :latest only."
required: false
type: string
default: ""
jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
# A version build checks out its tag, not main HEAD — so it is reproducible and a
# failed/lost release build can be re-run later without picking up newer commits.
ref: ${{ inputs.version != '' && format('v{0}', inputs.version) || '' }}
# The Docker context has no .git, so the checked-out commit is passed in as a build-arg
# and stamped into the assembly's informational version (shown by /v2/Version).
- name: Resolve checked-out commit
id: rev
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# The exact version tag for release builds; :latest only when that version is the newest
# tag, so re-publishing an old version never moves :latest backwards.
- name: Compute image tags
id: tags
env:
VERSION: ${{ inputs.version }}
run: |
if [ -z "$VERSION" ]; then
echo "tags=ghcr.io/chutch3/kenku:latest" >> "$GITHUB_OUTPUT"
exit 0
fi
tags="ghcr.io/chutch3/kenku:${VERSION}"
newest=$(git ls-remote --tags origin 'v*' | awk -F/ '{print $NF}' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
if [ "v${VERSION}" = "$newest" ]; then
tags="${tags},ghcr.io/chutch3/kenku:latest"
fi
echo "tags=${tags}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.7.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3.12.0
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (UI + API in one image)
uses: docker/build-push-action@v6.18.0
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/arm/v7
pull: true
push: true
build-args: |
VERSION=${{ inputs.version }}
GIT_SHA=${{ steps.rev.outputs.sha }}
tags: ${{ steps.tags.outputs.tags }}