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. # # act_runner runs JS actions (actions/checkout) with whatever `node` is on the # job container's PATH, so each job installs one before checkout. # # 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-alpine steps: - name: Install node for JS actions run: apk add --no-cache nodejs - uses: actions/checkout@v4 # act_runner injects ACTIONS_CACHE_URL, so this hits the runner-local # cache server (config: cache.dir) instead of re-downloading modules. - uses: actions/cache@v4 with: path: | ~/go/pkg/mod ~/.cache/go-build key: go-${{ hashFiles('go.sum') }} restore-keys: go- - run: go vet ./... && go test ./... image: needs: test runs-on: ubuntu-latest container: image: docker:27-cli # The runner already injects /var/run/docker.sock (declaring it again is a # duplicate mount error). CasaOS keeps app definitions under # /var/lib/casaos/apps, which is whitelisted in the runner's valid_volumes; # mount it at /apps so the restart step sees the installed compose file. volumes: - /var/lib/casaos/apps:/apps env: IMAGE: docker.notsosm.art/knox steps: - name: Install node for JS actions run: apk add --no-cache nodejs git - uses: actions/checkout@v4 - name: Check the daemon run: 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