feat: implement real-time collaborative workspace with Monaco editor,… #127
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 Cloud Run & Firebase | |
| on: | |
| push: | |
| branches: | |
| - main | |
| env: | |
| PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| REGION: us-central1 | |
| BACKEND_SERVICE_NAME: portfolio-backend | |
| ARTIFACT_REGISTRY: portfolio-images | |
| jobs: | |
| deploy-backend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Google Auth | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
| - name: 'Set up Cloud SDK' | |
| uses: 'google-github-actions/setup-gcloud@v2' | |
| - name: 'Debug GCP Info' | |
| run: |- | |
| echo "Project ID: ${{ env.PROJECT_ID }}" | |
| echo "Region: ${{ env.REGION }}" | |
| echo "Repository Name: ${{ env.ARTIFACT_REGISTRY }}" | |
| echo "Listing repositories in ${{ env.REGION }}:" | |
| gcloud artifacts repositories list --location=${{ env.REGION }} || echo "Failed to list repos" | |
| - name: 'Docker Auth' | |
| run: |- | |
| gcloud auth configure-docker ${REGION}-docker.pkg.dev --quiet | |
| - name: Build and Push Container | |
| run: |- | |
| docker build -t ${REGION}-docker.pkg.dev/${PROJECT_ID}/${ARTIFACT_REGISTRY}/${BACKEND_SERVICE_NAME}:${{ github.sha }} ./server | |
| docker push ${REGION}-docker.pkg.dev/${PROJECT_ID}/${ARTIFACT_REGISTRY}/${BACKEND_SERVICE_NAME}:${{ github.sha }} | |
| - name: Deploy to Cloud Run | |
| id: deploy | |
| uses: 'google-github-actions/deploy-cloudrun@v2' | |
| with: | |
| service: ${{ env.BACKEND_SERVICE_NAME }} | |
| region: ${{ env.REGION }} | |
| image: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.ARTIFACT_REGISTRY }}/${{ env.BACKEND_SERVICE_NAME }}:${{ github.sha }} | |
| flags: '--allow-unauthenticated' | |
| env_vars: | | |
| NODE_ENV=production | |
| MONGODB_URI=${{ secrets.MONGODB_URI }} | |
| JWT_ACCESS_SECRET=${{ secrets.JWT_ACCESS_SECRET }} | |
| CLIENT_URL=https://${{ secrets.GCP_PROJECT_ID }}.web.app | |
| outputs: | |
| backend_url: ${{ steps.deploy.outputs.url }} | |
| deploy-frontend: | |
| runs-on: ubuntu-latest | |
| needs: deploy-backend | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Dependencies | |
| run: npm install | |
| working-directory: ./client | |
| - name: Build Frontend | |
| run: npm run build | |
| working-directory: ./client | |
| env: | |
| VITE_API_URL: ${{ needs.deploy-backend.outputs.backend_url }}/api | |
| - name: Deploy to Firebase Hosting | |
| uses: FirebaseExtended/action-hosting-deploy@v0 | |
| with: | |
| repoToken: '${{ secrets.GITHUB_TOKEN }}' | |
| firebaseServiceAccount: '${{ secrets.GCP_SA_KEY }}' | |
| channelId: live | |
| projectId: ${{ secrets.GCP_PROJECT_ID }} |