From 3e36c0857640683b1ca6a8d0e520f6fd377bfa87 Mon Sep 17 00:00:00 2001 From: zhanghongtong Date: Sat, 20 Mar 2021 11:06:39 +0800 Subject: [PATCH] chore(CI): update workflows --- .github/workflows/build_slim_packages.yaml | 2 +- .github/workflows/elvis_lint.yaml | 7 ++++++- .github/workflows/run_gitlint.yaml | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml index d1b00a2f1..2e29292ec 100644 --- a/.github/workflows/build_slim_packages.yaml +++ b/.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 diff --git a/.github/workflows/elvis_lint.yaml b/.github/workflows/elvis_lint.yaml index af824f034..1fdbeba87 100644 --- a/.github/workflows/elvis_lint.yaml +++ b/.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 diff --git a/.github/workflows/run_gitlint.yaml b/.github/workflows/run_gitlint.yaml index 9d5d72ab6..01b35461f 100644 --- a/.github/workflows/run_gitlint.yaml +++ b/.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<> $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