瀏覽代碼

Add workflows for helm release (#2632)

* add workflows

* fix

* add flow

* fix

* change names

* add comments

* fix helm.yaml file

* fix helm.yaml

* fix helm.yaml

* fix realse-helm.yaml
Narekmat 2 年之前
父節點
當前提交
09e06e7854
共有 2 個文件被更改,包括 57 次插入9 次删除
  1. 20 9
      .github/workflows/helm.yaml
  2. 37 0
      .github/workflows/release-helm.yaml

+ 20 - 9
.github/workflows/helm.yaml

@@ -1,14 +1,11 @@
 name: Helm
 name: Helm
 on:
 on:
-  pull_request:
-    types: [ 'opened', 'edited', 'reopened', 'synchronize' ]
-    paths:
-      - "charts/**"
-
-  schedule:
-    # * is a special character in YAML so you have to quote this string
-    - cron:  '0 8 * * 3'
-
+ pull_request:
+  types: ["opened", "edited", "reopened", "synchronize"]
+  branches:
+   - 'master'
+  paths:
+   - "charts/**"
 jobs:
 jobs:
   build-and-test:
   build-and-test:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
@@ -30,3 +27,17 @@ jobs:
               echo $version;
               echo $version;
               helm template --kube-version $version --set ingress.enabled=true charts/kafka-ui -f charts/kafka-ui/values.yaml | kubeval --additional-schema-locations https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master --strict -v $version;
               helm template --kube-version $version --set ingress.enabled=true charts/kafka-ui -f charts/kafka-ui/values.yaml | kubeval --additional-schema-locations https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master --strict -v $version;
             done
             done
+      #check, was helm version increased in Chart.yaml?
+      - name: Check version
+        shell: bash
+        run: |
+          git fetch
+          git checkout master
+          helm_version_old=$(cat charts/kafka-ui/Chart.yaml  | grep version | awk  '{print $2}')
+          git checkout $GITHUB_HEAD_REF
+          helm_version_new=$(cat charts/kafka-ui/Chart.yaml  | grep version | awk  '{print $2}')
+          echo $helm_version_old
+          echo $helm_version_new
+          if [[ "$helm_version_new" > "$helm_version_old" ]]; then exit 0 ; else exit 1 ; fi
+
+

+ 37 - 0
.github/workflows/release-helm.yaml

@@ -0,0 +1,37 @@
+name: Release helm
+on:
+ push:
+    branches:
+     - master
+    paths:
+      - "charts/**"
+
+jobs:
+ release-helm:
+  runs-on:
+   ubuntu-latest
+  steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 1
+
+      - run: |
+          git config user.name github-actions
+          git config user.email github-actions@github.com
+
+      - uses: azure/setup-helm@v1
+
+      - name: add chart #realse helm with new version
+        run: |
+          echo "VERSION=$(cat charts/kafka-ui/Chart.yaml  | grep version | awk '{print $2}')" >> $GITHUB_ENV
+          MSG=$(helm package  charts/kafka-ui)
+          git fetch origin
+          git stash
+          git checkout -b gh-pages origin/gh-pages
+          helm repo index .
+          git add -f ${MSG##*/} index.yaml
+          git commit -m "release ${{ env.VERSION }}"
+          git push
+      - uses: rickstaa/action-create-tag@v1 #create new tag
+        with:
+          tag: "charts/kafka-ui-${{ env.VERSION }}"