slackapi / slack-github-action

Send data into Slack using this GitHub Action!
MIT License
954 stars 148 forks source link

Feature Request: Get Slack Username from Email #349

Open thejeff77 opened 1 week ago

thejeff77 commented 1 week ago

Description

I was able to do this in Jenkins, and looking for a way to do it in GHA. I need a way to lookup a slack user's username via their email.

Github actions give context on the committer via email, but obv github doesn't provide slack user data. In order to tag a user directly, being able to lookup the user's slack id so you can tag them or message them directly would be incredibly valuable.

What type of issue is this? (place an x in one of the [ ])

Requirements (place an x in each of the [ ])


Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

1. 2. 3.

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

mwbrooks commented 1 week ago

Hey @thejeff77 👋🏻

Thanks for the posting the question - it's a pretty common use-case to try to look up a user based on their email address and totally makes sense that you'd need to do this from our GitHub Action.

Since you've done this in Jenkins, I imagine you're already aware of the Slack API method users.lookupByEmail?

We don't have a slick way of calling this method from the GitHub Action, but we're playing around with a few ideas for you. Hopefully, together we can find a solution for you until slack-github-action@v2 (branch) lands! Expect a follow-up response soon!

zimeg commented 1 week ago

@thejeff77 adding to the suggestion of using the users.lookupByEmail method, it should be possible to make this call with a curl request and scoped token like so:

    - name: Find the Slackbot user ID
      run: |
        curl -X POST -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
          -H "Content-type: application/json" \
          --data '{"email":"slackbot@example.com"}' \
          https://slack.com/api/users.lookupByEmail

Although making use of the response might require a bit of bash magic in this step...

As @mwbrooks mentioned, we're chipping away at @v2 of this GitHub Action which will have more support for calling Slack API methods and making use of these responses in later steps.

We'll check that this method works well in these updates and will continue to share updates with changes for that version!

thejeff77 commented 3 days ago

@zimeg looking forward to it!