Skip to content

A way to set specific branches triggered on push (commit). #664

Description

@junaruga

Description

I want to run Packit as a service on push for the specific branches. I want to trigger any branches except master branch. Below is my current .packit.yml configuration. Is there a way to do it? I check the https://dashboard.packit.dev/pipelines page. But it seems nothing triggers in the push for a branch with the following configuration. Does the current branch: syntax support the regular expression?

jobs:
  - &copr
    job: copr_build
    trigger: pull_request
    enable_net: true
    targets:
      # https://packit.dev/docs/configuration/#available-copr-build-targets
      - fedora-rawhide-x86_64
      - fedora-rawhide-i386
      - fedora-rawhide-aarch64
      - fedora-rawhide-ppc64le
      - fedora-rawhide-s390x

  - <<: *copr
    # Run on push to any branch.
    trigger: commit

Benefit

Users can test their commit by running on CI before sending the PR to the target repository.

Importance

GitHub Actions have the feature to set the triggered branches using the wildcard by branches and branches-ignore syntax.
https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#using-filters
https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#example-excluding-branches

Workaround

  • There is an existing workaround that can be used until this feature is implemented.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)

Activity

  1. mfocko commented on Jun 5, 2023

    @mfocko
    Member

    I have implemented a way to process regex for the branch option on trigger: commit. It was part of experiments with the merge queues on GitHub, so it is not yet documented and well tested.

    I would suggest trying:

      - <<: *copr
        # Run on push to any branch.
        trigger: commit
        branch: '^(?!.*master)'
  2. changed the title [-]A way to set specific branches triggered on push (cocmmit).[/-] [+]A way to set specific branches triggered on push (commit).[/+] on Jun 5, 2023
  3. junaruga commented on Jun 6, 2023

    @junaruga
    Author

    Thanks for the suggestion. Why is it the branch: '^(?!.*master)' rather than branch: '^(?!master)'?

  4. junaruga commented on Jun 6, 2023

    @junaruga
    Author

    Checking the Python regular expression syntax (?!...) at https://docs.python.org/3/library/re.html. If you trim the heading and tailing spaces of the value of the branch. I think we can omit the ^ in the '^(?!master)' too.

  5. junaruga commented on Jun 6, 2023

    @junaruga
    Author

    I experimented.

    $ python3 --version
    Python 3.11.3
    
    $ python3
    ...
    >>> import re
    >>> p = re.compile('^(?!master)')
    >>> print(p.match('master'))
    None
    >>> print(p.match(' master'))
    <re.Match object; span=(0, 0), match=''>
    >>> print(p.match('amaster'))
    <re.Match object; span=(0, 0), match=''>
    >>> print(p.match('mastera'))
    None
    
    >>> import re
    >>> p = re.compile('(?!master)')
    >>> print(p.match('master'))
    None
    >>> print(p.match('amaster'))
    <re.Match object; span=(0, 0), match=''>
    >>> print(p.match(' master'))
    <re.Match object; span=(0, 0), match=''>
    >>> print(p.match('mastera'))
    None
    >>> print(p.match('master '))
    None
    
  6. junaruga commented on Jun 6, 2023

    @junaruga
    Author

    It seems I was able to run the CI on the push on a branch (wip/packit-copr-push).
    https://dashboard.packit.dev/results/copr-builds/810710

    +    branch: '(?!master)'
    
  7. mfocko commented on Jun 6, 2023

    @mfocko
    Member

    Thanks for letting me know, I'll transfer it to the repo with docs, so it can be properly documented.

    ad the suggested regex, it was just a guess :)

  8. transferred this issue frompackit/packiton Jun 6, 2023
  9. junaruga commented on Jun 6, 2023

    @junaruga
    Author

    Okay. Thanks for implementing this!

  10. moved this from new to backlog in Packit Kanban Boardon Jun 8, 2023
  11. nforro commented on Oct 16, 2025

    @nforro
    Member

    Still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/generalNot tied to a specific areacomplexity/single-taskRegular task; should be done within daysgain/lowDoesn't bring much value to usersimpact/lowAffects only few of the userskind/documentationImprovements to docs

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions