Skip to content

Conversation

blink-so[bot]
Copy link

@blink-so blink-so bot commented Sep 9, 2025

Problem

Currently, CI runs twice for feature branches with pull requests:

  1. Push event: When pushing commits to feature branch
  2. Pull request event: When opening/updating the PR

This wastes CI resources and creates duplicate status checks.

Solution

Updated the GitHub Actions workflow triggers to follow best practices:

Before:

on:
  push:
  pull_request:

After:

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

Behavior Changes

Scenario Before After
Push to feature branch ✅ CI runs ❌ No CI run
Open PR from feature branch ✅ CI runs ✅ CI runs
Push to main branch ✅ CI runs ✅ CI runs
Update PR (push to feature branch) ✅ CI runs twice ✅ CI runs once

Benefits

  • Eliminates duplicate CI runs for feature branches with PRs
  • Saves CI resources and reduces build queue times
  • Follows GitHub Actions best practices
  • Maintains full test coverage - all PRs are still tested
  • Preserves main branch protection - pushes to main still trigger CI

Testing

This PR itself will demonstrate the fix:

  • ✅ No CI run when pushing the feature branch
  • ✅ CI runs once when the PR is opened
  • ✅ No duplicate runs

Updated GitHub Actions workflow to:
- Only run on pushes to main branch
- Run on all pull requests to main branch

This prevents duplicate CI runs when pushing feature branches that
already have pull requests open, following GitHub Actions best practices.

Before:
- Push to feature branch: CI runs
- Open PR from feature branch: CI runs again (duplicate)

After:
- Push to feature branch: No CI run
- Open PR from feature branch: CI runs once
- Push to main: CI runs

Co-authored-by: f0ssel <[email protected]>
@f0ssel f0ssel merged commit 602dd2f into main Sep 9, 2025
2 checks passed
@f0ssel f0ssel deleted the blink/fix-ci-triggers branch September 9, 2025 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant