From affc6fcc7ae3f24c901a2c6d9234fa4f48abd2e5 Mon Sep 17 00:00:00 2001 From: frieZZerr Date: Mon, 3 Jun 2024 21:12:48 +0200 Subject: [PATCH] Create deploy pipeline Add pipeline for github actions --- .github/workflows/deploy.yaml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..6b58388 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,46 @@ +name: Deploy to Google Cloud + +on: + push: + branches: + - project_10 + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Authenticate in Google Cloud + uses: 'google-github-actions/auth@v2' + with: + credentials_json: '${{ secrets.GCP_SA_KEY }}' + + - name: Set up Google Cloud SDK + uses: google-github-actions/setup-gcloud@v0.2.0 + with: + service_account_key: ${{ secrets.GCP_SA_KEY }} + project_id: ${{ secrets.GCP_PROJECT_ID }} + + - name: Build and Push Docker images + run: | + gcloud auth configure-docker + docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/frontend:${{ github.sha }} ./project_10/client + docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/backend:${{ github.sha }} ./project_10/server + docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/frontend:${{ github.sha }} + docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/backend:${{ github.sha }} + + - name: Deploy Frontend to Cloud Run + uses: google-github-actions/deploy-cloudrun@v0.2.0 + with: + service: frontend-service + image: gcr.io/${{ secrets.GCP_PROJECT_ID }}/frontend:${{ github.sha }} + region: europe-central2 + + - name: Deploy Backend to Cloud Run + uses: google-github-actions/deploy-cloudrun@v0.2.0 + with: + service: backend-service + image: gcr.io/${{ secrets.GCP_PROJECT_ID }}/backend:${{ github.sha }} + region: europe-central2