5151 script : |
5252 set -euo pipefail
5353 _d() { printf '%s\n' "[vox-deploy] $*"; }
54+ _dcompose_diag() {
55+ _d "--- docker compose ps -a ---"
56+ docker compose ps -a 2>&1 | sed 's/^/[vox-deploy] /' || true
57+ _d "--- docker compose logs (last 400 lines) ---"
58+ docker compose logs --tail 400 2>&1 | sed 's/^/[vox-deploy] /' || true
59+ }
5460 # appleboy/ssh-action runs bash --noprofile --norc; docker/git often live in /usr/local/bin
5561 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
5662 _d "whoami=$(whoami) pwd=$(pwd) PATH=$PATH"
@@ -61,10 +67,10 @@ jobs:
6167 _d "IMAGE=${IMAGE} branch=${{ github.event.inputs.branch }} deploy_path=${{ github.event.inputs.deploy_path }}"
6268 cd "${{ github.event.inputs.deploy_path }}"
6369 _d "repo root $(pwd)"
70+ # Match remote tip (avoids failed ff-only pulls after branch switches / divergent local clones)
6471 git fetch origin "${{ github.event.inputs.branch }}"
65- git checkout "${{ github.event.inputs.branch }}"
66- git pull --ff-only origin "${{ github.event.inputs.branch }}"
67- _d "--- after git pull ---"
72+ git checkout -B "${{ github.event.inputs.branch }}" "origin/${{ github.event.inputs.branch }}"
73+ _d "--- after git sync ---"
6874 git rev-parse HEAD && git status -sb || true
6975 if [ ! -d deploy ]; then
7076 _d "ERROR: $(pwd)/deploy is not a directory"; exit 1
99105 echo "${TOKEN}" | docker login ghcr.io -u "${U}" --password-stdin
100106 fi
101107 _d "docker compose pull vox-server"
102- docker compose pull vox-server || { _d "ERROR: docker compose pull failed (see above)"; exit 1; }
108+ docker compose pull vox-server || { _d "ERROR: docker compose pull failed (see above)"; _dcompose_diag; exit 1; }
103109 _d "docker compose up -d"
104- docker compose up -d || { _d "ERROR: docker compose up failed"; exit 1; }
110+ docker compose up -d || { _d "ERROR: docker compose up failed"; _dcompose_diag; exit 1; }
105111 _d "nginx reload (conf.d bind mount)"
106- docker compose exec -T nginx nginx -s reload || { _d "ERROR: nginx reload failed"; exit 1; }
112+ docker compose exec -T nginx nginx -s reload || { _d "ERROR: nginx reload failed"; _dcompose_diag; exit 1; }
107113 _d "finished OK"
0 commit comments