Files
knox/.gitea/workflows/build.yml
T
david a422de2ab6
build / test (push) Failing after 1m50s
build / image (push) Has been skipped
ci: use debian-based job images so act_runner can inject node (#8)
2026-11-03 23:05:39 -08:00

85 lines
2.5 KiB
YAML

name: build
# Build the knox image on the dhg.lol daemon through the runner's docker socket.
#
# The registry on the host requires htpasswd auth, and the established pattern
# for self-built apps here is a locally-tagged image consumed with
# `pull_policy: never` (see apps/plant-dashboard). Building against the host
# daemon keeps that contract and means a knox change needs no registry
# credentials at all.
#
# Images are Debian-based on purpose: act_runner injects a glibc Node into the
# job container to run JS actions (actions/checkout), which fails on musl.
#
# Deployment stays with tf-net: this workflow only makes the new image available
# and restarts the stack when the app is already installed.
on:
push:
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- "Dockerfile"
- ".dockerignore"
- ".gitea/workflows/build.yml"
workflow_dispatch:
concurrency:
group: knox-build
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
container:
image: golang:1.27
steps:
- uses: actions/checkout@v4
- run: go vet ./... && go test ./...
image:
needs: test
runs-on: ubuntu-latest
container:
image: golang:1.27
# Whitelisted in the runner config (valid_volumes): the host daemon and
# the CasaOS app directory where compose files live.
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /apps:/apps
env:
IMAGE: docker.notsosm.art/knox
steps:
- uses: actions/checkout@v4
- name: Install docker CLI
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends docker.io >/dev/null
docker version --format '{{.Server.Version}}'
- name: Build image on the host daemon
run: |
set -eu
git config --global --add safe.directory "$GITHUB_WORKSPACE" || true
# .git is present in the checkout, so the binary records the commit
# it was built from (`knox --version`).
docker build \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
-t "$IMAGE:latest" \
-t "$IMAGE:${GITHUB_SHA}" \
.
docker run --rm "$IMAGE:latest" --version
- name: Restart the app if it is installed
run: |
set -eu
if [ ! -f /apps/knox/docker-compose.yml ]; then
echo "apps/knox is not installed yet; image built, skipping restart"
exit 0
fi
cd /apps/knox
docker compose up -d
docker compose ps