Skip to content

Update deploy.yml

Update deploy.yml #10

Workflow file for this run

name: Build & Deploy Backend (GHCR → EC2)

Check failure on line 1 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy.yml

Invalid workflow file

(Line: 51, Col: 9): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory, (Line: 52, Col: 9): Unexpected value 'appleboy/ssh-action@v1.2.0', (Line: 54, Col: 5): Unexpected value 'host', (Line: 55, Col: 5): Unexpected value 'username', (Line: 56, Col: 5): Unexpected value 'key', (Line: 57, Col: 5): Unexpected value 'script', (Line: 54, Col: 5): There's not enough info to determine what you meant. Add one of these properties: cancel-timeout-minutes, container, continue-on-error, defaults, env, environment, outputs, runs-on, secrets, services, snapshot, steps, timeout-minutes, uses, with
on:
push:
branches: [ main ]
permissions:
contents: read
packages: write
jobs:
build-push-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# (Spring) 빌드
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*','**/gradle-wrapper.properties') }}
- run: ./gradlew clean bootJar --no-daemon
# GHCR 로그인(액션에서만 필요)
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 이미지 푸시 (latest + sha)
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/dmu-debugvisual/debugvisual-backend:latest
ghcr.io/dmu-debugvisual/debugvisual-backend:${{ github.sha }}
# EC2 배포 (익명 pull)
- name: Deploy on EC2 (compose pull/up)
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }} # ec2-user
key: ${{ secrets.EC2_KEY }} # PEM 전체 내용
script: |
set -e
LOCK=/tmp/debugvisual.deploy.lock
(
flock -n 9 || { echo 'Another deploy is running. Skip.'; exit 0; }
cd ~/apps/debugvisual
docker logout ghcr.io || true # 익명 pull 강제
docker compose pull --ignore-pull-failures backend
docker compose up -d --wait --remove-orphans backend
docker image prune -af || true
curl -skI https://api.zivorp.com/healthz | head -n1
) 9>$LOCK