Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
name: Netlify Deploy
name: Netlify Deploy (Pull Request)

on:
push:
pull_request:
branches:
- main # 프로덕션 배포
- develop # 테스트 배포
- main # main 브랜치에 PR이 열리면 실행
- develop # develop 브랜치에 PR이 열리면 실행

jobs:
deploy:
runs-on: ubuntu-latest

steps:
# 코드 체크아웃
- name: Checkout code
uses: actions/checkout@v3

# 의존성 설치
- name: Install dependencies
run: npm install

# 프로젝트 빌드
- name: Build project
run: npm run build

# Netlify로 배포
- name: Deploy to Netlify
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: '<Your Site ID>' # Netlify에서 제공된 Site ID
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
npm install -g netlify-cli
if [ "${{ github.ref_name }}" = "main" ]; then
netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --prod --message "Production Deploy from main"
elif [ "${{ github.ref_name }}" = "develop" ]; then
netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --branch=develop --message "Develop Deploy"
fi
DEPLOY_OUTPUT=$(netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --message "Deploy for PR to develop" --json)
DEPLOY_URL=$(echo $DEPLOY_OUTPUT | jq -r .deploy_url)
echo "Deploy URL: $DEPLOY_URL"
echo "TEST_DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV

# PR에 배포 URL을 주석으로 추가
- name: Add deploy URL to PR comment
if: github.event_name == 'pull_request'
run: |
curl -s -X POST \
-H "Authorization: token ${{ secrets.MY_PAT }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d '{"body": "Test site deployed: '"$TEST_DEPLOY_URL"'"}'
Loading