[공통] Vercel 배포 진행 및 Github Actions CI/CD 추가 #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pr-preview | |
on: | |
# main, develop 브랜치를 향해 PR 올리면 임시 배포되도록 설정 | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
branches: ['main', 'develop'] | |
# 권한 설정 | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
id-token: write | |
pages: write | |
deployments: write | |
# 동시성 설정 | |
concurrency: preview-${{ github.ref }} | |
jobs: | |
deploy-preview: | |
runs-on: ubuntu-latest | |
# 버셀과 연결 | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
steps: | |
# workflow에 속한 레포지토리에 접근할 수 있도록 설정 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Get Vercel Environment Variables | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
# 종속성 설치 및 프로젝트 빌드 | |
- name: Install and Build | |
run: yarn install && yarn build | |
- name: Build Project Artifacts | |
run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
id: deploy | |
run: | | |
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > vercel-output.txt | |
echo "preview_url=$(cat vercel-output.txt)" >> $GITHUB_OUTPUT | |
# PR 프리뷰 배포 | |
- name: Comment PR with Preview URL | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
🎉 구현한 기능 Preview: ${{ steps.deploy.outputs.preview_url }} |