Skip to content
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

Labels added after PR creation do not trigger Slack messages #1594

Open
gergelyke-dd opened this issue Jan 5, 2023 · 15 comments
Open

Labels added after PR creation do not trigger Slack messages #1594

gergelyke-dd opened this issue Jan 5, 2023 · 15 comments
Assignees
Labels

Comments

@gergelyke-dd
Copy link

Describe the bug
Once an PR is created, labels added to it do not trigger Slack notifications

To Reproduce
Steps to reproduce the behavior:

  1. Subscribe to pull using a label as a filter
  2. Create a PR
  3. Once the PR is open, add the label you created the filter for
  4. No Slack message is triggered

Expected behavior
Slack message is triggered

@sanjeev9160
Copy link
Contributor

@gergelyke-dd The way label filter works is that it filters any PR event based on the label present in it. When the PR is opened and if there is no label attached to it while opening, we don't process that event and we drop it. So there is no PR notification for the opened PR. Now later if we add label then we don't have any parent(opened) PR card for it so the PR edited(label) event can't do anything.
So to make sure that it works correctly, attach the label when you are opening the PR. That way you will receive the notification. Thanks.

@gergelyke-dd
Copy link
Author

@sanjeev9160 any chance there's a workaround here for the use-case outlined above?

We'd like to use tags to signal different life-cycle events of a PR, and for that we'd like to use Slack notifications

@gileswells
Copy link

@sanjeev9160 would it be appropriate to make a feature request that there be a new trigger added to this integration that fires based on when a label is added or removed from a PR / issue?

My proposed use case:
When using the stale GitHub Action we want to be able to add the stale label and then have this GitHub integration pick up on that and send an update to the channel the subscription is in. Basically we'd like to have this command function at any point during a PR's lifecycle.

/github subscribe [repo] labeled:{name: "label name", event: "[added|removed|both]", type: "[issue|pull|both]"}
defaults would, i'd assume, be both for event and type properties.

If desired I can make this it's own issue ticket.

@sanjeev9160
Copy link
Contributor

@gergelyke-dd @gileswells I have added it as a Feature request into the backlog. Thanks.

@dannysauer
Copy link

FWIW: this also breaks anyone using an autolabel github action, since those labels need the PR to be opened before the action can run. If there's a better way to make labels appear in the PR based on changed files before the PR is opened, I'm all ears.

@dannysauer
Copy link

Perhaps relevant: the alert does come through when a labeled PR is closed. Upon close of a PR with a filtered label which wasn't present at opening, the "new PR" message gets created, and the close comment gets posted as a reply which is CC'd to the channel as normal. So it seems there is logic hidden away somewhere which can create the top level post upon later filter-matching events. ;)

@benebene84
Copy link

Currently we manage this with a Slack workflow:

name: Send Slack Notifications

on:
  pull_request:
    types: [labeled]

jobs:
  build:
    if: contains(github.event.pull_request.labels.*.name, 'ready for review')
    runs-on: ubuntu-latest

    steps:
      - name: Send custom JSON data to Slack workflow
        id: slack
        uses: slackapi/slack-github-action@v1.23.0
        with:
          payload: |
            {
              "pr_name": "${{ github.event.pull_request.title }}",
              "pr_link": "${{ github.event.pull_request.html_url }}"
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

But it would be great if this would work with the Github App in slack as well, then we could ditch this workflow.

@jodator
Copy link

jodator commented Apr 25, 2023

@gergelyke-dd @gileswells I have added it as a Feature request into the backlog. Thanks.

That would be an awesome feature because it promotes automation. We also have labels added to PRs based on team who created it. This would allow us to filter PRs from our team only.

The goal is to do less "by hand" when creating a PR :)

ps.: I see that a close PR event creates a message on a slack channel (with configured filters for labels).

@AnthonyBarbier
Copy link

Any update on that? (Can the backlog be seen anywhere?)

We're interested in that feature too (For the same reasons as some of the other people mentioned: after the CI run succeeded a "needs review" label is added to the PR at which point it would be great to be able to send a Slack notification to people).

@pyrocks
Copy link

pyrocks commented Sep 12, 2023

I have the exact same need...

@melibe23
Copy link

melibe23 commented Sep 13, 2023

This is really needed on my end too. I would prefer not to make a workflow just for a label notification.

@c-hardch
Copy link

Hi @sanjeev9160 When this will be fixed?

@edengo
Copy link

edengo commented Oct 17, 2023

Would like to add my name to this request.

Use Case: Code Owners have requested an automated way to know when a Pull is "Urgent" and requires their immediate priority over other reviews. Ideally this can be added as a label at anytime and then a slack notification will be sent alerting a slack channel with all owners in it for visibility.

@bigcakes
Copy link

We also need this feature to be able to add labels after the fact through automation and still have them routed properly

@gmolk
Copy link

gmolk commented Dec 12, 2023

Is this feature still in the backlog? This would be a game-changer for us in terms of automation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests