From 2e233abfd6442f72b028bcd40862303ba9f62689 Mon Sep 17 00:00:00 2001 From: Vargha Csongor Date: Mon, 11 Mar 2024 20:39:03 +0100 Subject: [PATCH] update kube actions --- .github/workflows/auth-service-cd.yml | 36 +++++++++++++++++++++------ .github/workflows/backend-cd.yml | 36 +++++++++++++++++++++------ .github/workflows/deploy_zitadel.yml | 3 ++- 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/.github/workflows/auth-service-cd.yml b/.github/workflows/auth-service-cd.yml index 5fbbfad..387fdb3 100644 --- a/.github/workflows/auth-service-cd.yml +++ b/.github/workflows/auth-service-cd.yml @@ -1,18 +1,38 @@ name: Release Auth service to Docker Hub and Deploy to Kubernetes on: - push: -# branches: -# - 'main' - paths: - - "auth-service/**" - - "deployment/auth-service/**" + push: + paths: + - "auth-service/**" + - "deployment/auth-service/**" + - ".github/workflows/auth-service-cd.yml" jobs: docker: name: Build and Push Auth-service image to Docker Hub runs-on: ubuntu-latest steps: + - uses: actions/github-script@v6 + id: create_image_tag + with: + script: | + if (context.issue.number) { + return "pr" + context.issue.number; + } else if(github.ref == 'refs/heads/main') { + return 'latest'; + } else { + return "pr" + ( + await github.rest.repos.listPullRequestsAssociatedWithCommit({ + commit_sha: context.sha, + owner: context.repo.owner, + repo: context.repo.repo, + }) + ).data[0].number; + } + result-encoding: string + - name: Image tag + run: echo '${{steps.create_image_tag.outputs.result}}' + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -27,9 +47,11 @@ jobs: with: push: true context: "{{defaultContext}}:auth-service" - tags: vcscsvcscs/gheritage-auth-service:latest + tags: vcscsvcscs/gheritage-auth-service:${{steps.create_image_tag.outputs.result}} + deployment: name: Deploy to Kubernetes + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: docker steps: diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index 50a8e64..072ad79 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -1,18 +1,38 @@ name: Release Backend service to Docker Hub and Deploy to Kubernetes on: - push: -# branches: -# - 'main' - paths: - - "backend/**" - - "deployment/backend/**" + push: + paths: + - "backend/**" + - "deployment/backend/**" + - ".github/workflows/backend-cd.yml" jobs: docker: name: Build and Push Backend image to Docker Hub runs-on: ubuntu-latest steps: + - uses: actions/github-script@v6 + id: create_image_tag + with: + script: | + if (context.issue.number) { + return "pr" + context.issue.number; + } else if(github.ref == 'refs/heads/main') { + return 'latest'; + } else { + return "pr" + ( + await github.rest.repos.listPullRequestsAssociatedWithCommit({ + commit_sha: context.sha, + owner: context.repo.owner, + repo: context.repo.repo, + }) + ).data[0].number; + } + result-encoding: string + - name: Image tag + run: echo '${{steps.create_image_tag.outputs.result}}' + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -27,9 +47,11 @@ jobs: with: push: true context: "{{defaultContext}}:backend" - tags: vcscsvcscs/gheritage-backend-service:latest + tags: vcscsvcscs/gheritage-backend-service:${{steps.create_image_tag.outputs.result}} + deployment: name: Deploy to Kubernetes + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: docker steps: diff --git a/.github/workflows/deploy_zitadel.yml b/.github/workflows/deploy_zitadel.yml index ca0e59d..9344121 100644 --- a/.github/workflows/deploy_zitadel.yml +++ b/.github/workflows/deploy_zitadel.yml @@ -5,6 +5,7 @@ on: # - main paths: - 'deployment/zitadel_values.yaml' + - '.github/workflows/deploy_zitadel.yml' jobs: deployment: @@ -18,7 +19,7 @@ jobs: KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} with: args: apply -f deployment/certs-job.yaml - + - name: 'Deploy Database' uses: 'vimeda/helm@v1' with: