integrations / slack

Bring your code to the conversations you care about with GitHub's integration for Slack
https://slack.github.com/
MIT License
3.09k stars 486 forks source link

Use slack usernames when referring to GitHub user activity #435

Open elliotblackburn opened 6 years ago

elliotblackburn commented 6 years ago

Loving the integration so far, we just started using it! Since there's a way to authenticate with the plugin via /github login, I was thinking it should be possible to use slack usernames when subscribed alerts are pulled through. For example at the moment we're getting something like the following:

BlueHatbRit
Deleted branch `feature/alert-new-sso-user`

My GitHub username is "BlueHatbRit", but my slack username in the instance of my companies workspace is "elliot". It'd be good if we could instead render:

elliot (BlueHatbRit)
Deleted branch `feature/alert-new-sso-user`

Where clicking on "elliot" might link to my slack profile, and clicking on "BlueHatbRit" might link to my github profile (or both to my github profile).

jplaisted commented 1 year ago

I'm gonna be that guy, sorry.

I want to opt out of mentions entirely. I enjoy the slack integration to see it as a channel of activity in a passive manner. I can go to the slack channel to see updates when I'm in review mode.

I'm not okay with what has now become (to me) notification spam. If I review 20 dependabot PRs, I'll now get 20*N slack notifications for it. Cool, I approved it. Cool, dependabot merged it. Do I need my mac / phone to make noises and show a pop up for these? No.

I figured maybe /github signout was the solution based on discussions here, but that now completely stopped the subscriptions :/

Edit: muting channels is not really an option either. While I like seeing if a channel has unread messages, that's not the deal breaker. I think the deal breaker is it'll still have other clutter, like threads. Each PR is a thread, and the bot posts updates to them when updates happen. Since I was in the OP as a reviewer, now my thread view is filled with spam.

Edit 2: Although, I'm also not sure why this only just now started to happen if the changes were made to the integration in February.

Edit 3: Ok maybe this is mostly solvable in slack, I guess I can right click a channel -> change notifications -> nothing. Not clear if that'll still cause thread-view clutter though.

smitt04 commented 1 year ago

@jplaisted

Edit: muting channels is not really an option either. While I like seeing if a channel has unread messages, that's not the deal breaker. I think the deal breaker is it'll still have other clutter, like threads. Each PR is a thread, and the bot posts updates to them when updates happen. Since I was in the OP as a reviewer, now my thread view is filled with spam.

you can turn off threads with /github settings if that is what you prefer

dtlary25 commented 1 year ago

Any update on this feature? I would like my team members and i to receive notifications with our slack names instead of github usernames. Anyone knows how to achieve that?

tking16 commented 1 year ago

Does this work yet? It's been like 5 years πŸ˜‚

thereis commented 1 year ago

LOL, 5y passed and no one from their team had a look in this task xD

papito commented 1 year ago

I wrote a prototype that did this years ago, and this time I spent a few months building a SaaS equivalent @ http://friendlyfire.tech

It lets you associate GitHub reviewers with Slack handles, will notify of PR comments, pause assignments if you have an OOO Slack emoji, select reviewers based on file matches (UI peeps, backend peeps, and so on). Still an active work in progress.

Not "selling" anything. If you try it now, that integration will be free. I am just looking for feedback.

kkiani commented 1 year ago

+1

highcastlee commented 1 year ago

Similar to felipecao's comment, but by following this suggestion, you don't need to hardcode anything.


I'm not sure if my comment will be helpful, but I'm leaving it here for someone.

I implemented a task in GitHub Actions CI where I perform a Slack mention using the committer information from the deployment pull request (PR).

I obtained the PR's committer information through octokit, and the committer.name and committer.email are collected from the git config information registered in the company's repository. git config user.email {useremail}

I retrieved the slack user id by using users.lookupByEmail() method(slack/web-api) with the company email obtained from GitHub.

Finally, by sending <@{userId}> string in a Slack notification, the mention is successful.

In CI workflow, you can run the following main.ts as a script to return the string needed for Slack mentions.

// .yaml
     (...)
  - name: Run script to get slack ids
    id: get-slack-ids
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
    working-directory: ./somewhere
    run: |
      echo "slack-ids=$(yarn start ${{github.ref}})" >> $GITHUB_OUTPUT
    (...)
// main.ts
async function main(ref) {
  try {
    const tag = ref.replace('refs/tags/', '');
    const lastTagBody = await getLastTagBody(tag);
    const prNumbers = getPRNumbersByTag(lastTagBody);
    const committers = await getCommittersByPRs(prNumbers);
    const slackUsers = await getSlackUsers(committers);
    const mentionIds = slackUsers
      .map((slackInfo) => (slackInfo.id ? `<@${slackInfo.id}>` : `@${slackInfo.name}`))
      .join(' ');

    process.stdout.write(mentionIds);
  } catch (error) {
    console.error(error);
    process.exit(1);
  }
}

도움이 λ λž‘κ°€ λͺ¨λ₯΄κ² λ„€μš”. ν–‰μš΄μ„ λΉ•λ‹ˆλ‹€. πŸš€

nicholaspshaw commented 4 months ago

Also would appreciate this feature

mveldurthy commented 4 months ago

This is the feature that I am eagerly anticipating.