8000 feat: Support filtering workflows using on.<> filters and events by john-tipper · Pull Request #2729 · nektos/act · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Support filtering workflows using on.<> filters and events #2729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

john-tipper
Copy link

resolves #2489

This PR adds a non-breaking change to add a --apply-event-filters flag.

  • When not set, there is no change to Act's existing behaviour.
  • When set, Act will filter workflows using the on.<> filters (paths, paths_ignore, tags, tags_ignore, branches, branches_ignore).

Limitations:

  • for push events, filtering paths is done using the commits referenced in the GitHub Webhook event which I think this is where GHA gets its information.
  • for pull_request and pull_request_target events, there is no guarantee that Act will actually be running with access to the actual git repo that's in GitHub (either locally on disk or via the network). I've elected for now to not handle this case, so workflows that set path filters.

More detailed thoughts on paths and pull request events:

GitHub says it does a 3 dot diff between base and head (https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-comparing-branches-in-pull-requests)

"The three-dot comparison shows the difference between the latest common commit of both branches (merge base) and the most recent version of the topic branch."

We could get the 2 SHA values from githubPullRequestEvent, but we'd have to decide whether we want to:

  • read from git on disk to perform the diff, perhaps from working directory or by reference to the path of the workflow files
  • clone from repo (requires credentials)
  • use the GitHub API (requires credentials)
  • do something else
  • do nothing

I've elected to do nothing for now, happy to consider adding this in later if we can agree the way forward.

Additional changes:

I removed a section of dead code around filtering, given that it just fed the list/graph output but didn't do anything else. That printing logic has been moved further down in root.go to be able to use variables that are defined later.

@john-tipper john-tipper changed the title Support filtering workflows using on.<> filters and events feat: Support filtering workflows using on.<> filters and events Apr 11, 2025
@john-tipper john-tipper force-pushed the #2489-filter-workflows-by-events branch from f445413 to 8a77428 Compare April 12, 2025 00:02
@mergify mergify bot added the needs-work Extra attention is needed label Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-work Extra attention is needed size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

act push includes runs that specify branches that don't match my current branch
1 participant
0