Files
nas-tools/.gitea/workflows/deploy-dev.yml
T
Gan, Jimmy 3e62abfc65
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 1m5s
Run Tests / Backend Tests (push) Failing after 2m46s
Run Tests / Frontend Tests (push) Failing after 1m59s
Run Tests / Test Summary (push) Failing after 14s
fix: clone repo into /tmp for runner accessibility
Runner container doesn't have access to /volume1/repos, so clone
into /tmp which is accessible. Clean up after deployment.
2026-04-06 19:34:10 +08:00

91 lines
3.3 KiB
YAML

name: Deploy Dashboard (Dev)
on:
push:
branches: [dev]
paths:
- 'dashboard/**'
- '.gitea/workflows/deploy-dev.yml'
concurrency:
group: deploy-dashboard-dev
cancel-in-progress: true
jobs:
deploy-dev:
runs-on: nas
steps:
- name: Checkout repository
run: |
# Clone into a temp directory accessible by runner
WORK_DIR="/tmp/nas-tools-deploy-$$"
rm -rf "$WORK_DIR"
git clone http://gitea:3000/jimmy/nas-tools.git "$WORK_DIR"
cd "$WORK_DIR"
git checkout ${{ github.sha }}
echo "WORK_DIR=$WORK_DIR" >> $GITHUB_ENV
- name: Warm mirror cache for base images
run: |
set -u
mirror_host="127.0.0.1:5501"
if command -v curl >/dev/null 2>&1; then
if curl -fsS "http://${mirror_host}/v2/" >/dev/null; then
echo "Registry mirror is healthy at ${mirror_host}"
else
echo "Warning: registry mirror health check failed at ${mirror_host}; continuing with normal pull path"
fi
else
echo "Warning: curl is unavailable; skipping explicit mirror health check"
fi
prewarm_base_image() {
image_ref="$1"
mirror_ref="${mirror_host}/library/${image_ref}"
echo "Attempting mirror pre-pull: ${mirror_ref}"
if timeout 60 docker pull "${mirror_ref}"; then
docker tag "${mirror_ref}" "${image_ref}"
echo "Mirror pre-pull succeeded for ${image_ref}"
else
echo "Warning: mirror pre-pull failed for ${image_ref}; continuing with normal pull during build"
fi
}
prewarm_base_image "node:20-alpine"
prewarm_base_image "python:3.12-slim"
- name: Build dev image
run: |
cd $WORK_DIR
export DOCKER_API_VERSION=1.43
DOCKER_BUILDKIT=0 docker build --cache-from nas-dashboard-dev:latest -t nas-dashboard-dev:latest dashboard/
- name: Sync runtime compose file
run: |
mkdir -p /volume1/docker/nas-dashboard
cp $WORK_DIR/dashboard/docker-compose.dev.yml /volume1/docker/nas-dashboard/docker-compose.dev.yml
- name: Deploy dev
run: |
set -euo pipefail
export DOCKER_API_VERSION=1.43
cd /volume1/docker/nas-dashboard
# Clean up any legacy manual containers
docker rm -f nas-dashboard-dev 2>/dev/null || true
# Ensure network exists (create only if it doesn't exist)
if ! docker network inspect nas-dashboard_internal >/dev/null 2>&1; then
docker network create nas-dashboard_internal
fi
# Use a dedicated project name to avoid killing production (which is project 'nas-dashboard')
# and deploy using the synced compose file.
docker compose -f docker-compose.dev.yml -p nas-dashboard-dev down --remove-orphans || true
docker compose -f docker-compose.dev.yml -p nas-dashboard-dev up -d --build --pull never
# Connect to gitea_gitea network for database access (OPC_DB)
docker network connect gitea_gitea nas-dashboard-dev || true
- name: Cleanup
if: always()
run: |
rm -rf $WORK_DIR