瀏覽代碼

Workflows to deploy and remove custom env from branches (#1108)

* Bump tmpl from 1.0.4 to 1.0.5 in /kafka-ui-react-app (#1078)

* Bump tmpl from 1.0.4 to 1.0.5 in /kafka-ui-react-app

Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* npm audit fix was run for tests fix

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kamila Alekbaeva <kalekbaeva@provectus.com>
Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>

* test image build

* custom env deploy remove github workflows

* Update branch-remove.yml

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kamila Alekbaeva <kalekbaeva@provectus.com>
Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>
Co-authored-by: Azat Safin <azsafin@provectus.com>
azatsafin 3 年之前
父節點
當前提交
847b6ba074
共有 3 個文件被更改,包括 142 次插入0 次删除
  1. 99 0
      .github/workflows/branch-deploy.yml
  2. 40 0
      .github/workflows/branch-remove.yml
  3. 3 0
      charts/kafka-ui/index.yaml

+ 99 - 0
.github/workflows/branch-deploy.yml

@@ -0,0 +1,99 @@
+name: DeployFromBranch
+on:
+  workflow_dispatch:
+  pull_request:
+    types: ['labeled']
+jobs:
+  build:
+    if: ${{ github.event.label.name == 'status/feature_testing' }}
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: get branch name
+        id: extract_branch
+        run: |
+          hub pr checkout ${{ github.event.pull_request.number }}
+          branch_name=$(hub branch | grep "*" | sed -e 's/^\*//')
+          echo $branch_name
+          echo ::set-output name=branch::${branch_name}
+          tag=$(echo $branch_name |  sed 's/\//-/g' | sed 's/\./-/g' | sed 's/\_/-/g' |  cut -c1-32)
+          echo ::set-output name=tag::${tag}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      - name: Cache local Maven repository
+        uses: actions/cache@v2
+        with:
+          path: ~/.m2/repository
+          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+          restore-keys: |
+            ${{ runner.os }}-maven-
+      - name: Set up JDK 1.13
+        uses: actions/setup-java@v1
+        with:
+          java-version: 1.13
+      - name: Build
+        id: build
+        run: |
+          export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
+          echo "::set-output name=version::${VERSION}"
+          mvn clean package -Pprod -DskipTests
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+      - name: Set up Docker Buildx
+        id: buildx
+        uses: docker/setup-buildx-action@v1
+      - name: Cache Docker layers
+        uses: actions/cache@v2
+        with:
+          path: /tmp/.buildx-cache
+          key: ${{ runner.os }}-buildx-${{ github.sha }}
+          restore-keys: |
+            ${{ runner.os }}-buildx-
+      - name: Configure AWS credentials for Kafka-UI account
+        uses: aws-actions/configure-aws-credentials@v1
+        with:
+          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
+          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+          aws-region: eu-central-1
+      - name: Login to Amazon ECR
+        id: login-ecr
+        uses: aws-actions/amazon-ecr-login@v1
+      - name: Build and push
+        id: docker_build_and_push
+        uses: docker/build-push-action@v2
+        with:
+          builder: ${{ steps.buildx.outputs.name }}
+          context: kafka-ui-api
+          push: true
+          tags: 297478128798.dkr.ecr.eu-central-1.amazonaws.com/kafka-ui:${{ steps.extract_branch.outputs.tag }}
+          build-args: |
+            JAR_FILE=kafka-ui-api-${{ steps.build.outputs.version }}.jar
+          cache-from: type=local,src=/tmp/.buildx-cache
+          cache-to: type=local,dest=/tmp/.buildx-cache
+    outputs:
+      tag: ${{ steps.extract_branch.outputs.tag }}
+  make-branch-env:
+    needs: build
+    runs-on: ubuntu-latest
+    steps:
+      - name: clone
+        run: |
+          git clone https://azsafin:${{ secrets.KAFKA_UI_INFRA_TOKEN }}@gitlab.provectus.com/provectus-internals/kafka-ui-infra.git
+      - name: create deployment
+        run: |
+          cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
+          echo "Branch:${{ needs.build.outputs.tag }}"
+          ./kafka-ui-deployment-from-branch.sh ${{ needs.build.outputs.tag }}
+          git config --global user.email "azsafin@provectus.com"
+          git config --global user.name "azsafin"
+          git add ../kafka-ui-from-branch/*
+          git commit -m "added env:${{ needs.build.outputs.deploy }}" && git push || true
+      - name: make comment with deployment link
+        uses: peter-evans/create-or-update-comment@v1.4.5
+        with:
+          issue-number: ${{ github.event.pull_request.number }}
+          body: |
+            Custom deployment will be available at https://${{ needs.build.outputs.tag }}.internal.kafka-ui.provectus.io
+
+
+

+ 40 - 0
.github/workflows/branch-remove.yml

@@ -0,0 +1,40 @@
+name: RemoveCustomDeployment
+on:
+  workflow_dispatch:
+  pull_request:
+    types: ['unlabeled']
+jobs:
+  remove:
+    if: ${{ github.event.label.name == 'status/feature_testing' }}
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: get branch name
+        id: extract_branch
+        run: |
+          hub pr checkout ${{ github.event.pull_request.number }}
+          branch_name=$(hub branch | grep "*" | sed -e 's/^\*//')
+          echo $branch_name
+          echo ::set-output name=branch::${branch_name}
+          tag=$(echo $branch_name |  sed 's/\//-/g' | sed 's/\./-/g' | sed 's/\_/-/g' |  cut -c1-32)
+          echo ::set-output name=tag::${tag}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      - name: clone
+        run: |
+          git clone https://azsafin:${{ secrets.KAFKA_UI_INFRA_TOKEN }}@gitlab.provectus.com/provectus-internals/kafka-ui-infra.git
+      - name: remove env
+        run: |
+          cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
+          echo "Branch:${{ steps.extract_branch.outputs.tag }}"
+          ./delete-env.sh ${{ steps.extract_branch.outputs.tag }}
+          git config --global user.email "azsafin@provectus.com"
+          git config --global user.name "azsafin"
+          git add ../kafka-ui-from-branch/*
+          git commit -m "removed env:${{ needs.build.outputs.deploy }}" && git push || true
+      - name: make comment with deployment link
+        uses: peter-evans/create-or-update-comment@v1.4.5
+        with:
+          issue-number: ${{ github.event.pull_request.number }}
+          body: |
+            Custom deployment removed

+ 3 - 0
charts/kafka-ui/index.yaml

@@ -0,0 +1,3 @@
+apiVersion: v1
+entries: {}
+generated: "2021-11-11T12:26:08.479581+03:00"