Skip to content

How to only add label, not remove when PR is opened?Β #112

Closed

Description

@pllim

I have a labeler action set up for when PR is opened, using all your default settings. The labeler YAML is set up as such (relevant parts listed below):

Docs:
  - docs/*

coordinates:
  - '**/coordinates/**/*'

When astropy/astropy#11023 was opened, the only file changed was docs/coordinates/apply_space_motion.rst. By the labeler logic, it should apply Docs and coordinates.

However, the PR author already manually applied Docs label at creation time. As a result, the labeler ended up removing the Docs label. Is this a bug? How do I tell it to simply no-op when a label that should be applied is already there?

Screenshot 2020-11-10 234620

Hope you can help and thanks for such a useful action!

Activity

  1. pllim commented on Nov 11, 2020

    @pllim
    ContributorAuthor

    Strangely enough, accidental removal did not happen for astropy/astropy#11028 when the file changed was only docs/conf.py and Docs label was also applied manually when PR was opened.

    Screenshot 2020-11-11 101002

    Screenshot 2020-11-11 101107

    (The Action ran successfully but it was a no-op, as expected.)

  2. makecir commented on Feb 2, 2021

    @makecir

    There hasn't been much progress in the conversation, but I also want to solve this problem.
    By removing the manually attached tags, the benefits gained by labelar are diminished.

  3. ericdallo commented on Mar 16, 2021

    @ericdallo

    Any news here?

  4. adam-azarchs commented on Dec 23, 2021

    @adam-azarchs
    Contributor

    It looks like the problem is

    const syncLabels = !!core.getInput("sync-labels", { required: false });

    which is not correct because the default value is "false", and !!"false" == true.

  5. adam-azarchs commented on Dec 23, 2021

    @adam-azarchs
    Contributor

    Confirmed, you can work around this bug by setting

    sync-labels: ''

    in your workflow.

  6. liverpool1026 commented on May 24, 2022

    @liverpool1026

    Confirmed, you can work around this bug by setting

    sync-labels: ''

    in your workflow.

    Thanks for this, can also confirm this works in v4. Any plans to fix this properly in the next version?

  7. added a commit that references this issue on Oct 18, 2023
  8. added a commit that references this issue on Jan 2, 2024
  9. xSAVIKx commented on Jul 19, 2024

    @xSAVIKx

    This still may happen with v5 action if the labels are added by the user at the time that's very close to the action run:
    image

    User added labels at 2024-07-19T15:07:34Z. Bot added his own at 2024-07-19T15:07:35Z.

    And bot started running at 2024-07-19T15:07:34Z as per GH action logs. So my guess is that it read labels, then user added his labels, then bot applied the rules and has overridden some of the labels the user has previously added.

    WF config:

    # .github/workflows/auto-labeler.yaml
    name: "Pull Request Labeler"
    on:
      pull_request_target:
        types: [ opened, reopened, synchronize ]
    
    jobs:
      labeler:
        permissions:
          contents: read
          pull-requests: write
        runs-on: ubuntu-22.04
        steps:
          - uses: actions/labeler@v5
            with:
              sync-labels: false
              dot: true
              configuration-path: .github/labeler.yaml
    

    Related rules:

    "/web":
      - any:
          - changed-files:
              - any-glob-to-any-file:
                  - SOME FILES
    javascript:
      - any:
          - changed-files:
              - any-glob-to-any-file:
                  - src/js/**
    
  10. added a commit that references this issue on Dec 18, 2024
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions