瀏覽代碼

chore(CI): update workflows

zhanghongtong 4 年之前
父節點
當前提交
3e36c08576
共有 3 個文件被更改,包括 19 次插入4 次删除
  1. 1 1
      .github/workflows/build_slim_packages.yaml
  2. 6 1
      .github/workflows/elvis_lint.yaml
  3. 12 2
      .github/workflows/run_gitlint.yaml

+ 1 - 1
.github/workflows/build_slim_packages.yaml

@@ -25,7 +25,7 @@ jobs:
         if make emqx-ee --dry-run > /dev/null 2>&1; then
           echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
           git config --global credential.helper store
-          echo "${{ secrets.CI_GIT_TOKEN }}" >> source/scripts/git-token
+          echo "${{ secrets.CI_GIT_TOKEN }}" >> ./scripts/git-token
           make emqx-ee-pkg
         else
           make emqx-pkg

+ 6 - 1
.github/workflows/elvis_lint.yaml

@@ -6,6 +6,11 @@ jobs:
   build:
     runs-on: ubuntu-20.04
     steps:
-      - uses: actions/checkout@v1
+      - uses: actions/checkout@v2
+      - name: Set git token
+        if: endsWith(github.repository, 'enterprise')
+        run: |
+          echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
+          git config --global credential.helper store
       - run: |
           ./scripts/elvis-check.sh $GITHUB_BASE_REF

+ 12 - 2
.github/workflows/run_gitlint.yaml

@@ -12,15 +12,25 @@ jobs:
         run: |
           sudo apt-get update
           sudo apt install gitlint
+      - name: Set auth header
+        if: endsWith(github.repository, 'enterprise')
+        run: |
+          echo 'AUTH_HEADER<<EOF' >> $GITHUB_ENV
+          echo "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" >> $GITHUB_ENV
+          echo 'EOF' >> $GITHUB_ENV
       - name: Run gitlint
+        shell: bash
         run: |
           pr_number=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
-          messages=$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/commits")
+          messages="$(curl --silent --show-error \
+                      --header "${{ env.AUTH_HEADER }}" \
+                      --header "Accept: application/vnd.github.v3+json" \
+                      "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/commits")"
           len=$(echo $messages | jq length)
           result=true
           for i in $( seq 0 $(($len - 1)) ); do
             message=$(echo $messages | jq -r .[$i].commit.message)
-            echo commit message: $message
+            echo "commit message: $message"
             status=0
             echo $message | gitlint -C ./.github/workflows/.gitlint || status=$?
             if [ $status -ne 0 ]; then