diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d947c59 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,38 @@ +name: Deploy to Google Cloud Run + +on: + push: + branches: + - main # Adjust the branch name as needed + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push Docker image + run: | + docker buildx build -t sleppp/inventory-backend --platform linux/amd64 . + docker tag sleppp/inventory-backend gcr.io/inventory-database-420916/inventory-backend + docker push gcr.io/inventory-database-420916/inventory-backend:latest + + - name: Set up Google Cloud SDK + uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + with: + project_id: ${{ secrets.GCP_PROJECT_ID }} + service_account_key: ${{ secrets.GCP_SA_KEY }} + export_default_credentials: true + + - name: Deploy to Cloud Run + run: | + gcloud run deploy inventory-backend \ + --image gcr.io/inventory-database-420916/inventory-backend \ + --platform managed \ + --region us-central1 \ + --allow-unauthenticated