Files
t5de-hub/.gitea/workflows/ci.yml
T
dhkatz d0f7e4d8c3
Release / release (push) Successful in 3s
CI / test (push) Successful in 7m26s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 5s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 5s
ci: only main's newest commit moves latest-main (#24)
Two merges close together can build out of order: on 2026-11-19, #22's image job finished two minutes after #23's and moved `:latest-main` back to #22's build, so staging ran without the OpenID provider.

Now a main push tags `:main-<commit>` always, and `:latest-main` only if its commit is still main's newest (`git ls-remote origin refs/heads/main`). Whichever finishes last, `:latest-main` ends on the newest commit. Tags (`vX.Y.Z`) are unchanged.

t5de-catalog and t5de-site have the same line, and need the same fix.

Two merges close together can build out of order: on 2026-11-19, #22's image job finished two minutes after #23's and moved `:latest-main` back to #22's build, so staging ran without the OpenID provider.

Now a main push tags `:main-<commit>` always, and `:latest-main` only if its commit is still main's newest (`git ls-remote origin refs/heads/main`). Whichever finishes last, `:latest-main` ends on the newest commit. Tags (`vX.Y.Z`) are unchanged.

t5de-catalog and t5de-site have the same line, and need the same fix.

Co-authored-by: dhkatz <[email protected]>
2026-11-19 10:18:22 +00:00

75 lines
2.6 KiB
YAML

# Type-checks, tests (the API against PGlite, an in-process Postgres) and builds the hub; then, for main and vX.Y.Z
# tags, builds its images and pushes them to git.t5de.dev. Komodo deploys them (dhkatz/infra); CI never deploys.
name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.4
- uses: actions/setup-node@v4
with:
node-version: 26
- name: Install
run: bun install --frozen-lockfile
- name: Check types
run: bun run check-types
- name: Test
run: bun run test
- name: Build
run: bun run build
# main → :latest-main and :main-<commit>; vX.Y.Z → :X.Y.Z, :X.Y and :latest. Built by the runner's Docker.
image:
needs: test
if: github.event_name == 'push'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- { image: t5de-hub-api, dockerfile: apps/api/Dockerfile }
- { image: t5de-hub-web, dockerfile: apps/web/Dockerfile }
steps:
- uses: actions/checkout@v4
- name: Build and push
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
IMAGE: git.t5de.dev/t5de/${{ matrix.image }}
DOCKERFILE: ${{ matrix.dockerfile }}
run: |
case "$GITHUB_REF" in
refs/heads/main)
version="main-${GITHUB_SHA::12}"; tags="$version"
# Merges close together can finish out of order: only main's newest commit moves latest-main (staging).
if [ "$(git ls-remote origin refs/heads/main | cut -f1)" = "$GITHUB_SHA" ]; then tags="latest-main $tags"
else echo "main has moved on since this commit: :$version only, latest-main stays"; fi ;;
refs/tags/v*)
version="${GITHUB_REF#refs/tags/v}"
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Not a vX.Y.Z tag: no image"; exit 0; }
tags="$version ${version%.*} latest" ;;
*) echo "Not main or a tag: no image"; exit 0 ;;
esac
echo "$REGISTRY_TOKEN" | docker login git.t5de.dev -u deploy --password-stdin
docker build -f "$DOCKERFILE" --label org.opencontainers.image.source="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
--label org.opencontainers.image.revision="$GITHUB_SHA" --label org.opencontainers.image.version="$version" \
$(for t in $tags; do echo "-t $IMAGE:$t"; done) .
for t in $tags; do docker push -q "$IMAGE:$t"; done
docker logout git.t5de.dev