[Fix/71] 게임 방 관련 구독 처리 및 버그 해결 #48
Workflow file for this run
This file contains hidden or 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: Deploy to S3 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| AWS_REGION: ap-northeast-2 | |
| NODE_VERSION: '18' | |
| jobs: | |
| # 빌드 및 테스트 | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GIT_PERSONAL_ACCESS_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Setup environment | |
| run: | | |
| # 환경 결정 (개발/프로덕션만) | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| ENV="production" | |
| else | |
| ENV="development" | |
| fi | |
| # 환경변수 설정 | |
| node scripts/setup-env.js $ENV setup | |
| echo "ENVIRONMENT=$ENV" >> $GITHUB_ENV | |
| - name: Validate environment | |
| run: npm run env:validate | |
| - name: Lint code | |
| run: npm run lint | |
| - name: Clean dist folder | |
| run: rm -rf dist | |
| - name: Build application | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| npm run build:prod | |
| else | |
| npm run build:dev | |
| fi | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| retention-days: 1 | |
| # S3 배포 | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GIT_PERSONAL_ACCESS_TOKEN }} | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-northeast-2 | |
| - name: Deploy to S3 | |
| run: | | |
| # 환경 결정 | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| ENV="production" | |
| DEPLOY_PATH="/" | |
| else | |
| ENV="development" | |
| DEPLOY_PATH="/dev/" | |
| fi | |
| BUCKET="${{ secrets.S3_BUCKET }}" | |
| echo "Deploying to $ENV environment..." | |
| echo "S3 Bucket: $BUCKET" | |
| echo "Deploy Path: $DEPLOY_PATH" | |
| # S3에 파일 업로드 (경로별 배포) | |
| aws s3 sync dist/ s3://$BUCKET$DEPLOY_PATH --delete --cache-control "public, max-age=31536000" | |
| # HTML 파일은 캐시하지 않음 | |
| aws s3 cp dist/index.html s3://$BUCKET$DEPLOY_PATH/index.html --cache-control "no-cache, no-store, must-revalidate" | |
| echo "Deployment completed successfully!" | |
| echo "Application URL: https://$BUCKET.s3-website.ap-northeast-2.amazonaws.com$DEPLOY_PATH" | |
| - name: CloudFront Invalidation | |
| env: | |
| CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID}} | |
| run: | | |
| aws cloudfront create-invalidation \ | |
| --distribution-id $CLOUD_FRONT_ID --paths "/*" | |
| - name: Notify deployment | |
| if: always() | |
| run: | | |
| if [[ "${{ job.status }}" == "success" ]]; then | |
| echo "✅ Deployment successful!" | |
| else | |
| echo "❌ Deployment failed!" | |
| fi |