From e2340f35a422da19bfef8a281b8cf518ffb7bcb5 Mon Sep 17 00:00:00 2001 From: slepp22 <102992553+slepp22@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:58:24 +0200 Subject: [PATCH 1/3] main_pipeline.yml --- .github/workflows/main.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/main.yml 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 From 2101662cd5ddf55023cfadfd7244b74db3a1abaf Mon Sep 17 00:00:00 2001 From: slepp22 <102992553+slepp22@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:00:07 +0200 Subject: [PATCH 2/3] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d947c59..d8df6b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: docker push gcr.io/inventory-database-420916/inventory-backend:latest - name: Set up Google Cloud SDK - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + uses: GoogleCloudPlatform/github-actions/setup-gcloud@v0.4.0 with: project_id: ${{ secrets.GCP_PROJECT_ID }} service_account_key: ${{ secrets.GCP_SA_KEY }} From 4fb2aabff56739872a29cea338578635e18d8f67 Mon Sep 17 00:00:00 2001 From: slepp22 <102992553+slepp22@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:02:18 +0200 Subject: [PATCH 3/3] Update main.yml --- .github/workflows/main.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d8df6b2..d819684 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,12 +22,10 @@ jobs: 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@v0.4.0 - with: - project_id: ${{ secrets.GCP_PROJECT_ID }} - service_account_key: ${{ secrets.GCP_SA_KEY }} - export_default_credentials: true + - name: Authenticate with Google Cloud + run: | + gcloud auth activate-service-account --key-file=service-account-key.json + gcloud config set project ${{ secrets.inventory-database-420916 }} - name: Deploy to Cloud Run run: |