From bd3fb5ce7473caa82b7a83de02b3a514ee0b26f0 Mon Sep 17 00:00:00 2001 From: Tanya Date: Thu, 8 Jan 2026 13:24:41 -0500 Subject: [PATCH] chore: Update CI workflow to trigger only on pull_request events This commit modifies the CI workflow to exclusively trigger on pull_request events, preventing duplicate runs caused by push events. It clarifies comments regarding event handling and emphasizes the importance of using pull requests for CI, enhancing the overall clarity and efficiency of the workflow. --- .gitea/workflows/ci.yml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 6e240cd..1c1218f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -2,15 +2,15 @@ name: CI on: - # Trigger on push for protected branches (master, dev) - direct pushes only - # Trigger on pull_request for all branches - PRs to master/dev and feature branches - # This separation prevents duplicate runs: pushes to master/dev don't conflict with PRs - push: - branches: [master, dev] + # Only trigger on pull_request events to avoid duplicate runs + # Push events to dev/master are disabled because they conflict with PR events + # PR events provide better context and eliminate duplicate workflow runs + # If you need CI on direct pushes (without PR), you can re-enable push events + # but be aware that duplicate runs may occur when both push and PR events fire pull_request: types: [opened, synchronize, reopened] - # PRs can target any branch, but we only test PRs targeting master/dev - # Feature branch PRs will also trigger, but they won't conflict with push events + # PRs targeting any branch will trigger CI + # This includes PRs to master/dev and feature branch PRs # Prevent duplicate runs when pushing to a branch with an open PR # This ensures only one workflow runs at a time for the same commit @@ -56,18 +56,9 @@ jobs: SKIP=0 - # Skip push events if this is a push (not a PR) to avoid duplicates with PR events - # PR events are preferred as they provide better context - if [ -z "$GITHUB_EVENT_PULL_REQUEST_NUMBER" ] && [ "$GITHUB_EVENT_NAME" = "push" ]; then - # For push events, only run on master/dev branches (protected branches) - # Feature branches should use PR events only - if [ "$BRANCH_NAME" != "master" ] && [ "$BRANCH_NAME" != "dev" ]; then - echo "Skipping CI: Push event on feature branch '$BRANCH_NAME' (use PR events instead)" - SKIP=1 - fi - # Note: For dev/master, we rely on concurrency group to prevent duplicates - # If both push and PR events fire, concurrency will cancel one - fi + # Note: Push events are disabled in workflow triggers to prevent duplicates + # Only pull_request events trigger this workflow now + # If push events are re-enabled, add skip logic here to prevent duplicates # Check branch name (case-insensitive) if [ $SKIP -eq 0 ] && echo "$BRANCH_NAME" | grep -qiF "$SKIP_PATTERN"; then