Code Issues Pull Requests Actions Packages Projects Releases 15 Wiki Activity Security Code Quality

ci: Implement skip logic for bot authors in commits-validation workflow to enhance commitlint execution

This commit is contained in:
tienbh committed 2026-11-27 11:31:37 +07:00 Verified
1 parent 11e15762fb
commit 3bbdf66a99
1 file changed
+29
@@ -10,18 +10,43 @@ concurrency:
env: env:
BUN_VERSION: 1.4.5 BUN_VERSION: 1.4.5
SKIP_AUTHORS: renovate renovatebot
jobs: jobs:
lint-commits-and-pr: lint-commits-and-pr:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Skip bot authors
id: author
env:
AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
set -euo pipefail
author=$(printf '%s' "$AUTHOR" | tr '[:upper:]' '[:lower:]')
skip=false
for name in $SKIP_AUTHORS; do
name=$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]')
if [[ "$author" == "$name" ]]; then
skip=true
break
fi
done
if [[ "$skip" == true || "$author" == *bot || "$author" == *'[bot]' ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Skipping commitlint for ${AUTHOR}"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Checkout code - name: Checkout code
if: steps.author.outputs.skip != 'true'
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
# Local config wins, in this order. Download the shared file only when none exist. # Local config wins, in this order. Download the shared file only when none exist.
- name: Resolve commitlint config - name: Resolve commitlint config
if: steps.author.outputs.skip != 'true'
id: commitlint-config id: commitlint-config
env: env:
COMMITLINT_REPO: ${{ vars.COMMITLINT_CONFIG_REPO || 'gitea/global-workflow' }} COMMITLINT_REPO: ${{ vars.COMMITLINT_CONFIG_REPO || 'gitea/global-workflow' }}
@@ -41,12 +66,14 @@ jobs:
echo "config=commitlint.config.js" >> "$GITHUB_OUTPUT" echo "config=commitlint.config.js" >> "$GITHUB_OUTPUT"
- name: Setup Bun - name: Setup Bun
if: steps.author.outputs.skip != 'true'
uses: oven-sh/setup-bun@v2 uses: oven-sh/setup-bun@v2
with: with:
bun-version: ${{ env.BUN_VERSION }} bun-version: ${{ env.BUN_VERSION }}
# Install outside the repo so bun does not migrate its lockfile or install its dependencies. # Install outside the repo so bun does not migrate its lockfile or install its dependencies.
- name: Install commitlint - name: Install commitlint
if: steps.author.outputs.skip != 'true'
run: | run: |
set -euo pipefail set -euo pipefail
dir="${RUNNER_TEMP}/commitlint" dir="${RUNNER_TEMP}/commitlint"
@@ -60,6 +87,7 @@ jobs:
echo "COMMITLINT_BIN=${dir}/node_modules/.bin/commitlint" >> "$GITHUB_ENV" echo "COMMITLINT_BIN=${dir}/node_modules/.bin/commitlint" >> "$GITHUB_ENV"
- name: Validate PR Title & Description (<= 500 chars) - name: Validate PR Title & Description (<= 500 chars)
if: steps.author.outputs.skip != 'true'
env: env:
PR_TITLE: ${{ github.event.pull_request.title }} PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }} PR_BODY: ${{ github.event.pull_request.body }}
@@ -72,6 +100,7 @@ jobs:
fi fi
- name: Validate All Commits in PR - name: Validate All Commits in PR
if: steps.author.outputs.skip != 'true'
env: env:
BASE_SHA: ${{ github.event.pull_request.base.sha }} BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }}