Skip to content

DP-311: 포인트 즉시 미반영 및 STREAK_7 배지 unlock 누락 수정 #150

DP-311: 포인트 즉시 미반영 및 STREAK_7 배지 unlock 누락 수정

DP-311: 포인트 즉시 미반영 및 STREAK_7 배지 unlock 누락 수정 #150

Workflow file for this run

name: Backend CD

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

View workflow run for this annotation

GitHub Actions / .github/workflows/cd.yml

Invalid workflow file

(Line: 99, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DEPLOY_STAGING_WEBHOOK_URL != '', (Line: 117, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DEPLOY_PRODUCTION_WEBHOOK_URL != ''
# develop 머지 시 스테이징 배포, main 머지 시 프로덕션 배포
# developV2 는 EC2 SSH 배포(deploy.yml)를 쓰므로 GHCR CD 는 실행하지 않되,
# 동일 브랜치 푸시 시 "0 jobs / workflow file issue" 실패를 막기 위해 no-op job 을 둔다.
on:
push:
branches:
- develop
- main
- developV2
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
name: Build & Push Docker Image
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
image_digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# develop → :staging
type=raw,value=staging,enable=${{ github.ref == 'refs/heads/develop' }}
# main → :latest + :v1.0.0 (git tag 있으면)
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=semver,pattern={{version}}
# 항상 붙는 커밋 SHA (롤백용)
type=sha,prefix=sha-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
id: build
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
develop-v2-cd-skip:
name: Skip GHCR CD on developV2
if: github.ref == 'refs/heads/developV2'
runs-on: ubuntu-latest
steps:
- name: EC2 배포는 deploy.yml 사용
run: |
echo "developV2 브랜치는 GHCR Backend CD 대신 .github/workflows/deploy.yml(EC2 SSH)로 배포합니다."
echo "이 워크플로는 실패하지 않도록 no-op 으로 종료합니다."
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: build-and-push
if: github.ref == 'refs/heads/develop'
environment: staging
steps:
# ── 배포 플랫폼 추상화 ──────────────────────────────────────────────────
# GitHub Repository Secret에 DEPLOY_STAGING_WEBHOOK_URL 설정 필요.
#
# [Railway]
# Railway 대시보드 → Service → Settings → Deploy Hooks → URL 복사
# https://backboard.railway.app/webhooks/deploy/...
#
# [EC2 / 자체 서버]
# 서버에 webhook receiver 설치 후 URL 설정 (예: https://api.devpick.kr/deploy)
# 또는 아래 deploy-ssh job으로 교체
# ────────────────────────────────────────────────────────────────────────
- name: Trigger deploy webhook (staging)
if: ${{ secrets.DEPLOY_STAGING_WEBHOOK_URL != '' }}
run: |
curl -s -o /dev/null -w "%{http_code}" \
-X POST "${{ secrets.DEPLOY_STAGING_WEBHOOK_URL }}" | \
grep -qE "^2[0-9]{2}$" && echo "Deploy triggered" || (echo "Deploy failed" && exit 1)
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: build-and-push
if: github.ref == 'refs/heads/main'
environment: production
steps:
# ── 배포 플랫폼 추상화 ──────────────────────────────────────────────────
# GitHub Repository Secret에 DEPLOY_PRODUCTION_WEBHOOK_URL 설정 필요.
# ────────────────────────────────────────────────────────────────────────
- name: Trigger deploy webhook (production)
if: ${{ secrets.DEPLOY_PRODUCTION_WEBHOOK_URL != '' }}
run: |
curl -s -o /dev/null -w "%{http_code}" \
-X POST "${{ secrets.DEPLOY_PRODUCTION_WEBHOOK_URL }}" | \
grep -qE "^2[0-9]{2}$" && echo "Deploy triggered" || (echo "Deploy failed" && exit 1)
# ── EC2/SSH 배포 시 이 job으로 위 deploy job을 교체 ─────────────────────────
# deploy-ssh:
# name: Deploy via SSH
# runs-on: ubuntu-latest
# needs: build-and-push
# if: github.ref == 'refs/heads/main'
# environment: production
# steps:
# - name: SSH & docker pull
# uses: appleboy/ssh-action@v1
# with:
# host: ${{ secrets.SSH_HOST }}
# username: ${{ secrets.SSH_USER }}
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# script: |
# docker pull ghcr.io/${{ github.repository }}:latest
# docker compose -f /opt/devpick/docker-compose.yml up -d --no-deps backend