Merge branch 'feature/25-mapbox-map-matching' #2
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 GCP Cloud Run | |
| on: | |
| push: | |
| branches: [ main ] | |
| env: | |
| PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| REGION: asia-northeast3 | |
| SERVICE_NAME: artrun-be | |
| REGISTRY: asia-northeast3-docker.pkg.dev | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '25' | |
| distribution: 'temurin' | |
| - name: Cache Gradle | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: ${{ runner.os }}-gradle- | |
| - name: Run tests | |
| run: chmod +x gradlew && ./gradlew test | |
| deploy: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| 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: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker ${{ env.REGISTRY }} --quiet | |
| - name: Build and push Docker image | |
| run: | | |
| IMAGE=${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/artrun/${{ env.SERVICE_NAME }}:${{ github.sha }} | |
| docker build -t $IMAGE . | |
| docker push $IMAGE | |
| - name: Deploy to Cloud Run | |
| run: | | |
| IMAGE=${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/artrun/${{ env.SERVICE_NAME }}:${{ github.sha }} | |
| gcloud run deploy ${{ env.SERVICE_NAME }} \ | |
| --image $IMAGE \ | |
| --region ${{ env.REGION }} \ | |
| --platform managed \ | |
| --allow-unauthenticated \ | |
| --set-env-vars "SPRING_PROFILES_ACTIVE=prod" \ | |
| --set-env-vars "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" \ | |
| --set-env-vars "DB_HOST=${{ secrets.DB_HOST }}" \ | |
| --set-env-vars "DB_PORT=${{ secrets.DB_PORT }}" \ | |
| --set-env-vars "DB_NAME=${{ secrets.DB_NAME }}" \ | |
| --set-env-vars "DB_USERNAME=${{ secrets.DB_USERNAME }}" \ | |
| --set-env-vars "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" \ | |
| --set-env-vars "REDIS_HOST=${{ secrets.REDIS_HOST }}" \ | |
| --set-env-vars "REDIS_PORT=${{ secrets.REDIS_PORT }}" \ | |
| --memory 1Gi \ | |
| --cpu 1 \ | |
| --port 8080 |