Deploy Backend #40
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 Backend | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'Branch to deploy from' | |
| required: true | |
| default: 'main' | |
| type: choice | |
| options: | |
| - main | |
| jobs: | |
| deploy-backend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.branch }} | |
| - name: Set up Google Cloud CLI | |
| uses: google-github-actions/setup-gcloud@v2 | |
| with: | |
| project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT }} | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| - name: Run Backend Tests | |
| working-directory: ./backend | |
| run: | | |
| echo "🧪 Running Go backend tests..." | |
| make test-all | |
| echo "📊 Running tests with coverage..." | |
| make test-coverage | |
| echo "⚡ Running performance benchmarks..." | |
| make benchmark | |
| - name: Deploy to Cloud Run | |
| working-directory: ./backend | |
| env: | |
| SERVICE_NAME: build-process-watcher-backend | |
| REGION: us-central1 | |
| GOOGLE_CLOUD_PROJECT: ${{ secrets.GOOGLE_CLOUD_PROJECT }} | |
| JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }} | |
| ADMIN_SECRET: ${{ secrets.ADMIN_SECRET }} | |
| run: make deploy | |
| - name: Get service URL | |
| id: get-url | |
| run: | | |
| SERVICE_URL=$(gcloud run services describe build-process-watcher-backend \ | |
| --region=us-central1 \ | |
| --format="value(status.url)") | |
| echo "service-url=$SERVICE_URL" >> $GITHUB_OUTPUT | |
| - name: Output service URL | |
| run: | | |
| echo "🚀 Backend deployed successfully!" | |
| echo "📡 Service URL: ${{ steps.get-url.outputs.service-url }}" |