From b1962eae27837785fd4ca1051e4e5c0f5f82f8b5 Mon Sep 17 00:00:00 2001 From: ilia Date: Sun, 28 Dec 2025 23:54:02 -0500 Subject: [PATCH] Refactor CI skip check to use a single pattern - Simplify the CI workflow by consolidating the skip check for both branch names and commit messages to a single case-insensitive pattern: @skipci. - Remove the previous multiple pattern checks to streamline the logic and improve readability. - Ensure that the CI process can be effectively skipped based on the new pattern, enhancing overall efficiency. --- .gitea/workflows/ci.yml | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 9cc53dc..608b098 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -22,45 +22,36 @@ jobs: - name: Check if CI should be skipped id: check run: | - # Centralized skip patterns - add more here as needed - SKIP_PATTERNS="skip-ci,no-ci,skip ci,[skip ci],[ci skip]" - + # Simple skip pattern: @skipci (case-insensitive) + # Works in branch names and commit messages + SKIP_PATTERN="@skipci" + # Get branch name (works for both push and PR) - # For PRs, GITHUB_HEAD_REF contains the branch name BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" - + # Get commit message (works for both push and PR) - # Try multiple sources for commit message COMMIT_MSG="${GITHUB_EVENT_HEAD_COMMIT_MESSAGE:-}" if [ -z "$COMMIT_MSG" ]; then - # For PRs, try pull request head commit COMMIT_MSG="${GITHUB_EVENT_PULL_REQUEST_HEAD_COMMIT_MESSAGE:-}" fi if [ -z "$COMMIT_MSG" ]; then - # Fallback: try to get from git log (requires checkout) COMMIT_MSG=$(git log -1 --pretty=%B 2>/dev/null || echo "") fi - + SKIP=0 - + # Check branch name (case-insensitive) - for pattern in $(echo $SKIP_PATTERNS | tr ',' ' '); do - if echo "$BRANCH_NAME" | grep -qi "$pattern"; then - echo "Skipping CI: branch name contains '$pattern'" - SKIP=1 - break - fi - done - + if echo "$BRANCH_NAME" | grep -qiF "$SKIP_PATTERN"; then + echo "Skipping CI: branch name contains '$SKIP_PATTERN'" + SKIP=1 + fi + # Check commit message (case-insensitive) if [ $SKIP -eq 0 ] && [ -n "$COMMIT_MSG" ]; then - for pattern in $(echo $SKIP_PATTERNS | tr ',' ' '); do - if echo "$COMMIT_MSG" | grep -qi "$pattern"; then - echo "Skipping CI: commit message contains '$pattern'" - SKIP=1 - break - fi - done + if echo "$COMMIT_MSG" | grep -qiF "$SKIP_PATTERN"; then + echo "Skipping CI: commit message contains '$SKIP_PATTERN'" + SKIP=1 + fi fi echo "skip=$SKIP" >> $GITHUB_OUTPUT