Merge pull request #132 from prgrms-aibe-devcourse/dev #80
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: Build and Deploy to ECR and Render | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| DOCKERHUB_REPOSITORY: lastdance-frontend | |
| jobs: | |
| build-and-push: | |
| name: Build and Push to Docker Hub | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image: ${{ steps.build-image.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPOSITORY }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha,format=short | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| id: build-image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| VITE_API_BASE_URL=${{ secrets.API_BASE_URL }} | |
| VITE_VAPID_PUBLIC_KEY=${{ secrets.VITE_VAPID_PUBLIC_KEY }} | |
| VITE_LOGO_URL=${{ secrets.VITE_LOGO_URL }} | |
| - name: Set output | |
| run: echo "image=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPOSITORY }}:latest" >> $GITHUB_OUTPUT | |
| deploy-to-render: | |
| name: Deploy to Render | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Deploy to Render | |
| uses: johnbeynon/render-deploy-action@v0.0.8 | |
| with: | |
| service-id: ${{ secrets.RENDER_SERVICE_ID }} | |
| api-key: ${{ secrets.RENDER_API_KEY }} | |
| - name: Deployment status | |
| run: | | |
| echo "✅ Deployment triggered successfully!" | |
| echo "🚀 Image: ${{ needs.build-and-push.outputs.image }}" | |
| echo "📦 Docker Hub Repository: ${{ env.DOCKERHUB_REPOSITORY }}" |