Files
ComfyUiPortalNext/.gitea/workflows/deploy.yml
T
chris.dumas c9fb2fa320
Deploy ComfyUI Jobs / deploy (push) Failing after 6s
Test and build ComfyUI Jobs / test-build (push) Successful in 11m4s
Preserve portal data during repository cutover
2026-10-02 19:39:58 +00:00

46 lines
2.5 KiB
YAML

name: Deploy ComfyUI Jobs
on:
push:
branches: [develop, qa, main]
jobs:
deploy:
runs-on: docker
steps:
- uses: actions/checkout@v4
with:
github-server-url: https://git.dumas.ddns.net
- name: Deploy selected environment
shell: bash
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
GITEA_REF: ${{ gitea.ref }}
run: |
set -Eeuo pipefail
mkdir -p ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
case "$GITEA_REF" in
refs/heads/develop) TARGET_DIR=/mnt/appdata/dev/ComfyUiPortal; COMPOSE_FILE=docker-compose.dev.yml; PROJECT=comfyuiportal-next-dev; PORT=7002; HEALTH_URL=http://192.168.1.15:7002; BRANCH=develop ;;
refs/heads/qa) TARGET_DIR=/mnt/appdata/qa/ComfyUiPortal; COMPOSE_FILE=docker-compose.qa.yml; PROJECT=comfyuiportal-next-qa; PORT=6002; HEALTH_URL=http://192.168.1.15:6002; BRANCH=qa ;;
refs/heads/main) TARGET_DIR=/mnt/appdata/prod/ComfyUiPortal; COMPOSE_FILE=docker-compose.prod.yml; PROJECT=comfyuiportal-next-prod; PORT=5002; HEALTH_URL=http://192.168.1.15:5002; BRANCH=main ;;
*) exit 0 ;;
esac
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/ComfyUiPortalNext.git
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "
set -Eeuo pipefail
mkdir -p '$TARGET_DIR'
if [ ! -d '$TARGET_DIR/.git' ]; then git init '$TARGET_DIR' && cd '$TARGET_DIR' && git remote add origin '$REPO_URL'; else cd '$TARGET_DIR' && git remote set-url origin '$REPO_URL'; fi
cd '$TARGET_DIR'
GIT_SSH_COMMAND='ssh -p 222 -o StrictHostKeyChecking=no' git fetch origin '$BRANCH'
git reset --hard 'origin/$BRANCH'
git clean -fdx -e data/ -e data/**
docker ps -q --filter publish=$PORT | xargs -r docker rm -f
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' down --remove-orphans || true
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' up -d --build
"
for attempt in 1 2 3 4 5 6; do curl --fail --silent --show-error --max-time 15 "$HEALTH_URL/api/health" && exit 0 || sleep 5; done
exit 1