npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@krauters/github-notifier

v0.13.0

Published

GitHub Notifier by Krauters – Post Open Pull Requests to Slack

Downloads

251

Readme

GitHub Action Status GitHub Marketplace License visitors

Version npm version GitHub Stars Forks

GitHub Issues Open PRs Commits per Month Contributors Last Commit

install size Code Size Repo Size

GitHub Notifier

Post Open Pull Requests to Slack.

GitHub Notifier Example

Simple Usage Example

GitHub Notifier is a TypeScript GitHub Action that posts open pull requests to Slack channels based on a scheduled job to remind team members to review pull requests.

Overview

This GitHub Action will query the GitHub (or GitHub Enterprise) org for all repositories (based on token permissions) and then, for each repository it will check for open pull requests. Then, it will attempt to match any related GitHub users to Slack users before building Slack blocks and posting a message (or multiple messages in the case of many PRs) to the designated Slack channels.

Quick start

  1. (Optional) Start by creating a repository called github-notifier.

    1. Whatever repo you use to host this workflow needs to be able to use GitHub Runners.
  2. Generate a GitHub token – You’ll need a fine-grained GitHub token that allows access to either all your repositories or just the ones you want notifications about.

    Here are the specific permissions the token needs:

    • Repository Administration: read – This lets the token list repositories within the organization.
    • Repository Pull Requests: read – Required to fetch details about pull requests.
    • Repository Contents: read – Allows the token to check the status of repository branch protections.
    • Organization Members: read – Required to retrieve GitHub email addresses for matching them with Slack users.

    Make sure the token is created by an organization owner, as it must belong to the organization where the relevant repositories and pull requests live.

    1. Save the token in your repository by going to Settings > Secrets and variables > Actions > New repository secret, and name it GH_TOKEN_GH_NOTIFIER.
  3. Create a Slack App either from scratch or by using a pre-defined manifest file.

    • To create from scratch: Start a new app called GitHub Notifier and add it to your Slack workspace.
    • To use the manifest: On the Slack App creation page, select "From an app manifest" and upload your manifest.json file to quickly set up the app.
    1. On the OAuth & Permissions page, assign the following scopes to the bot,

      • chat:write – So the bot can post messages in Slack channels.
      • users:read – To look up Slack users for matching with GitHub accounts.
      • users:read.email – Allows the bot to retrieve Slack user emails for matching with GitHub accounts.
      • chat:write.customize – This enables the bot to modify its display name and avatar when posting.
    2. On the OAuth & Permissions page, click Install To Workspace, then copy the User OAuth Token.

    3. Save this token in your repository at Settings > Secrets and variables > Actions > New repository secret, naming it SLACK_TOKEN_GH_NOTIFIER.

    4. Add the Slack app you just created to the relevant Slack channel(s) and note down the channel IDs for the workflow.

  4. Set up a workflow similar to this:

    # .github/workflows/github-notifier.yaml
    
    name: GitHub Notifier
    
    on:
      schedule:
      - cron: 0 15,17,19,21,23 * * 1-5
      workflow_dispatch:
    
    jobs:
      github-notifier:
        runs-on: ubuntu-latest
        steps:
        - uses: krauters/github-notifier@main
          with:
            github-token: ${{ secrets.GH_TOKEN_GH_NOTIFIER }}
            channels: C07L8EWB389
            slack-token: ${{ secrets.SLACK_TOKEN_GH_NOTIFIER }}

    For more details about available inputs, you can check out the action definition file, action.yaml.

Input Variables

See action.yaml for more detailed information.

| Name | Description | Required | Default | |-----------------------|---------------------------------------------------------------------------------------------|----------|----------| | github-token | Fine-grained GitHub token with necessary scopes for administration, PR details, and members.| Yes | | | slack-token | Permissions to post to Slack and perform user lookups. | Yes | | | channels | Comma-separated list of Slack channel IDs to post to. | Yes | | | with-archived | Include PRs from archived repositories. | No | false | | with-public | Include PRs from public repositories. | No | true | | with-drafts | Include draft PRs. | No | false | | No | false | | with-user-mentions | Allow Slack user mentions. | No | true | | repository-filter | Comma-separated list of repositories to scan. | No | | | base-url | Base GitHub API URL (e.g., https://api.github.com). | No | |

Troubleshooting

Error: An API error occurred: channel_not_found

This error means the Slack app probably wasn’t added to the channel you’re trying to post in.

Husky

Husky helps manage Git hooks easily, automating things like running tests or linting before a commit is made. This ensures your code is in good shape.

Pre-commit hooks run scripts before a commit is finalized to catch issues or enforce standards. With Husky, setting up these hooks across your team becomes easy, keeping your codebase clean and consistent.

Our Custom Pre-Commit Hook

This project uses a custom pre-commit hook to run npm run bundle. This ensures that our bundled assets are always up to date before any commit (which is especially important for TypeScript GitHub Actions). Husky automates this, so no commits will go through without a fresh bundle, keeping everything streamlined.

Contributing

The goal of this project is to continually evolve and improve its core features, making it more efficient and easier to use. Development happens openly here on GitHub, and we’re thankful to the community for contributing bug fixes, enhancements, and fresh ideas. Whether you're fixing a small bug or suggesting a major improvement, your input is invaluable.

License

This project is licensed under the ISC License. Please see the LICENSE file for more details.

🥂 Thanks Contributors

Thanks for spending time on this project.

References to this project