Files
maptool/.gitea/workflows/ci.yml
T
randy 71e638b459
CI / check (push) Successful in 7m3s
CI / deploy (push) Failing after 1s
Fix CI: host-mode runner has no Node.js for actions/checkout
Host-mode jobs run directly in the runner container instead of a
spawned per-job container, so JS actions like actions/checkout@v4
have no Node.js runtime to execute with. Replace it with a plain git
fetch/checkout in the deploy job.
2026-08-27 15:39:47 +02:00

77 lines
2.8 KiB
YAML

name: CI
on:
push:
pull_request:
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# No ruby-version input: the action auto-detects it from
# .ruby-version when the input is omitted (not "file", which isn't
# a recognized value and fails with "Unknown engine file").
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Ruby syntax check
run: find app.rb config lib -name "*.rb" -print0 | xargs -0 -n1 ruby -c
- name: App loads without errors
run: bundle exec ruby -e 'require_relative "app"'
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: JS syntax check
run: find public/js -name "*.js" -print0 | xargs -0 -n1 node --check
# Runs directly in the runner's own container (see the "host" label in the
# runner's config.yaml), not in an ephemeral per-job container — that's
# what gives this job access to /var/run/docker.sock (already mounted into
# the runner container) and to /srv/docker (bind-mounted there too, see
# docs/deployment.adoc). No systemd/sudo involved.
deploy:
needs: check
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: host
steps:
# Not actions/checkout@v4: it's a JS action and host-mode jobs run
# directly in the runner container, which has git but no Node.js.
- name: Checkout
run: |
rm -rf .git * .[!.]* 2>/dev/null
git init -q
git remote add origin "${{ gitea.server_url }}/${{ gitea.repository }}.git"
git -c http.extraHeader="Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
fetch --depth 1 origin "${{ gitea.sha }}"
git checkout -q FETCH_HEAD
# /srv/docker/maptool is the same path inside the runner container and
# on the real host (1:1 bind mount) — required so the relative bind
# mount `./data:/app/data` in docker-compose.yaml resolves to the
# correct real host path when the daemon creates the container.
#
# No rsync in the runner image, so this clears out everything in the
# target except data/ (uploaded GPX files, offline.pmtiles — never
# part of the git checkout in the first place, since it's gitignored)
# and copies the fresh checkout over, dropping .git afterwards.
- name: Sync to /srv/docker/maptool
run: |
mkdir -p /srv/docker/maptool
for f in /srv/docker/maptool/*; do
[ "$(basename "$f")" = "data" ] && continue
rm -rf "$f"
done
cp -a . /srv/docker/maptool/
rm -rf /srv/docker/maptool/.git
- name: Deploy
run: |
cd /srv/docker/maptool
docker compose -p maptool up --build -d