Fix SIGPIPE issue with 3-step deployment

- Separate tar → scp → unpack to avoid pipe failures
- Add SSH stability options (ConnectTimeout, ServerAliveInterval)
- Clean up temporary files after deployment
- Prevents Exit code 141 (SIGPIPE) errors
- Maintains atomic swap and backup functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
happybell80 2025-07-08 00:08:38 +09:00
parent f5ec562748
commit 3fb4618c6b

View File

@ -56,9 +56,15 @@ jobs:
ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} \ ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} \
"ls -la /var/run/docker.sock && id" "ls -la /var/run/docker.sock && id"
- name: Create deployment archive
run: tar czf deploy.tar.gz --exclude='.git' .
- name: Copy archive to NAS
run: scp -o ConnectTimeout=10 -o ServerAliveInterval=60 -P ${{ secrets.NAS_PORT }} deploy.tar.gz admin@${{ secrets.NAS_HOST }}:/tmp/
- name: Deploy with atomic swap - name: Deploy with atomic swap
run: | run: |
tar czf - --exclude='.git' . | ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} bash -s << 'EOF' ssh -o ConnectTimeout=10 -o ServerAliveInterval=60 -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF'
set -euo pipefail set -euo pipefail
DEPLOY=/volume1/homes/admin/nginx-infra DEPLOY=/volume1/homes/admin/nginx-infra
@ -66,7 +72,7 @@ jobs:
BACKUP=${DEPLOY}-backup-$(date +%Y%m%d%H%M%S) BACKUP=${DEPLOY}-backup-$(date +%Y%m%d%H%M%S)
# 1) tar로 임시 디렉터리에 풀기 # 1) tar로 임시 디렉터리에 풀기
cd "$TMPDIR" && tar xzf - cd "$TMPDIR" && tar xzf /tmp/deploy.tar.gz
# 2) 기존 배포물을 백업 # 2) 기존 배포물을 백업
if [ -d "$DEPLOY" ]; then if [ -d "$DEPLOY" ]; then
@ -85,4 +91,7 @@ jobs:
cd "$DEPLOY" cd "$DEPLOY"
docker-compose down 2>/dev/null || true docker-compose down 2>/dev/null || true
docker-compose up -d --build docker-compose up -d --build
# 6) 임시 파일 정리
rm -f /tmp/deploy.tar.gz
EOF EOF