62 lines
2.0 KiB
YAML
62 lines
2.0 KiB
YAML
# Type-checks and builds the website; then, for main and vX.Y.Z tags, builds its image and pushes it to git.t5de.dev.
|
|
# Komodo deploys it (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: 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
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build and push
|
|
env:
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
IMAGE: git.t5de.dev/t5de/t5de-site
|
|
run: |
|
|
case "$GITHUB_REF" in
|
|
refs/heads/main) version="main-${GITHUB_SHA::12}"; tags="latest-main $version" ;;
|
|
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 --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
|