How Do You Send Slack Notifications from GitHub Actions in Your Organization?

0
20
Asked By TechieBee2023 On

I'm trying to figure out the best way to set up Slack notifications from GitHub Actions in my organization. I came across Slack's example that uses the `users.lookupByEmail` method, which I believe could help me send messages to users based on their emails. However, to do this, I need to know the email of `${GITHUB_ACTOR}`. I tried using `gh api /users/$ACTOR`, but I keep getting `null` for the email field, which makes me think there might be a permissions issue or it's just not the right approach. I'd really appreciate it if anyone could share how they've successfully set this up!

5 Answers

Answered By SyncSavant On

We've addressed this by creating a mapping of Slack usernames to GitHub logins. Since we manage GitHub access through Infrastructure as Code (IaC), it was easy to pull in a JSON string mapping into a GitHub organization variable. This way, our Slack notification action can replace usernames appropriately before sending messages, making sure notifications reach the right people!

Answered By PipelinePro On

In our organization, we have a generic inbox for pipeline notifications and use a fixed Slack webhook URL for important notifications that need to go to a wider audience. Notifications intended specifically for a pull request author simply get added as comments on their PRs, which GitHub automatically emails out to them. This way, everything stays organized without bombarding anyone with unnecessary DMs!

Answered By CloudNinja42 On

We keep it simple but effective. Our CI pipelines send notifications through a pub/sub system, which we built to support various downstream integrations. Our engineering team uses a composite action to send messages, and they're routed through our notification service, which handles all the details efficiently.

Answered By SlackMaster99 On

It depends on what notifications you're looking to send. If you set up the GitHub app in Slack, it can handle a lot of events for you. Users can subscribe to pull requests, receive commit alerts, and more—all directly in a channel. Also, when users log into the GitHub app on Slack, it automatically connects their GitHub usernames to their Slack names, which simplifies things!

Answered By CodeWhisperer77 On

Make sure you've got the right permissions set up for both GitHub and Slack, as detailed in the documentation. If a user's email isn't set to public on their GitHub profile, it will return 'null.' So, users need to check their settings. Also, keep in mind that users might have personal emails associated with their GitHub accounts, which can complicate things if you’re trying to match emails with Slack identities. To avoid spamming users with direct messages, many teams prefer sending notifications to dedicated channels instead, like a general 'GitHub' channel or team-specific channels.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.