chore(CI): update workflows

This commit is contained in:
zhanghongtong 2021-03-20 11:06:39 +08:00 committed by tigercl
parent 99843e7b4b
commit 3e36c08576
3 changed files with 19 additions and 4 deletions

View File

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

View File

@ -6,6 +6,11 @@ jobs:
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: 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: | - run: |
./scripts/elvis-check.sh $GITHUB_BASE_REF ./scripts/elvis-check.sh $GITHUB_BASE_REF

View File

@ -12,15 +12,25 @@ jobs:
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt install gitlint 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 - name: Run gitlint
shell: bash
run: | run: |
pr_number=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') 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) len=$(echo $messages | jq length)
result=true result=true
for i in $( seq 0 $(($len - 1)) ); do for i in $( seq 0 $(($len - 1)) ); do
message=$(echo $messages | jq -r .[$i].commit.message) message=$(echo $messages | jq -r .[$i].commit.message)
echo commit message: $message echo "commit message: $message"
status=0 status=0
echo $message | gitlint -C ./.github/workflows/.gitlint || status=$? echo $message | gitlint -C ./.github/workflows/.gitlint || status=$?
if [ $status -ne 0 ]; then if [ $status -ne 0 ]; then