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

create-linked-clubhouse-story

v1.0.0

Published

A GitHub Action to automatically create a linked story on Clubhouse.io

Downloads

5

Readme

Create Linked Clubhouse Story

This is a GitHub Action that will automatically create a story on Clubhouse when a pull request is opened, unless the pull request already has a link to a Clubhouse story in the description.

Basic Usage

Create a Clubhouse API token, and store it as an encrypted secret in your GitHub repository settings. Check the GitHub documentation for how to create an encrypted secret. Name this secret CLUBHOUSE_TOKEN.

Create a file named clubhouse.yml in the .github/workflows directory of your repository. Put in the following content:

on:
  pull_request:
    types: [opened, closed]

jobs:
  clubhouse:
    runs-on: ubuntu-latest
    steps:
      - uses: singingwolfboy/[email protected]
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          clubhouse-token: ${{ secrets.CLUBHOUSE_TOKEN }}
          project-name: Engineering
          opened-state-name: Started
          merged-state-name: Done
          closed-state-name: Abandoned

The project-name variable should contain the name of the Clubhouse project that you want the Clubhouse story to be associated with. The opened-state-name, merged-state-name, and closed-state-name variables should contain the name of the state that you want the Clubhouse story to be in when the pull request is opened, merged, and closed, respectively.

Disabled for Built-In Integration

Clubhouse already has an integration with GitHub. It works for the opposite use-case, assuming that the Clubhouse story exists before the pull request is created.

This Action will specifically check for branch names that follow the naming convention for this built-in integration. Any branch name that contains sc-#### will be ignored by this Action, on the assumption that a Clubhouse story already exists for the pull request. The sc-#### must be separated from leading or following text with either a / or a -. So, branches named sc-1, prefix/sc-23, prefix-sc-123, sc-3456/suffix, sc-3456-suffux, prefix/sc-987/suffix would match, but xsc-123 and sc-987end would not.

Customizing the Pull Request Comment

You can customize the comment posted on pull requests using the comment-template variable, like this:

- uses: singingwolfboy/[email protected]
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    clubhouse-token: ${{ secrets.CLUBHOUSE_TOKEN }}
    project-name: Engineering
    opened-state-name: Started
    merged-state-name: Done
    closed-state-name: Abandoned
    comment-template: >-
      Thanks for the pull request! [I've created a Clubhouse story
      for you.]({{{ story.app_url }}})

This comment template is processed using the Mustache templating system. It receives the Story object returned from the Clubhouse API. Note that you may want to use the triple mustache syntax to disable HTML escaping.

GitHub will automatically process the comment text as Markdown, so you can use features like links and images if you make your comment template output valid Markdown, as shown above.

If you don't provide a comment template, this action will use this comment template by default: Clubhouse story: {{{ story.app_url }}}

Customizing the Clubhouse Story Title and Body

You can customize the Clubhouse title and description when creating stories using the story-title-template and story-description-template variables, like this:

- uses: singingwolfboy/[email protected]
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    clubhouse-token: ${{ secrets.CLUBHOUSE_TOKEN }}
    project-name: Engineering
    opened-state-name: Started
    merged-state-name: Done
    closed-state-name: Abandoned
    story-title-template: >-
      {{{ payload.repository.name }}} - {{{ payload.pull_request.title }}}
    story-description-template: >-
      :zap: New story created for pull request [**{{{ payload.pull_request.title }}}**]({{{ payload.pull_request.html_url }}})
      in repo **{{{ payload.repository.name }}}**.
      {{{ #payload.pull_request.body }}}
        The body of the PR is: {{{ payload.pull_request.body }}}
      {{{ /payload.pull_request.body }}}

The story title and body templates are processed using the Mustache templating system. It receives the Payload object returned from the GitHub API. Note that you may want to use the triple mustache syntax to disable HTML escaping. Also Clubhouse supports full Markdown formatting, emojis, and @ mentions. Feel free to use them to your heart's desire. :heart_eyes_cat:

If you don't provide a title or body template, this action will simply use the Pull Request Title ({{{ payload.pull_request.title }}}) and Pull Request Body ({{{ payload.pull_request.body }}}) by default.

User Map

This Action does its best to automatically assign the created Clubhouse story to the person who created the GitHub pull request. However, due to limitations of the GitHub API and the Clubhouse API, this will only work automatically when the GitHub user and the Clubhouse user share the same primary email address. Even though both services allow you to add multiple secondary email addresses, only the primary email address is exposed in the API.

As a workaround, you can maintain a user map, which teaches this Action how to map GitHub users to Clubhouse users. The user map should be passed in the with section, and due to the limitations of GitHub Actions, must be a JSON formatted string. Here's an example:

- uses: singingwolfboy/[email protected]
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    clubhouse-token: ${{ secrets.CLUBHOUSE_TOKEN }}
    project-name: Engineering
    user-map: |
      {
        "octocat": "12345678-9012-3456-7890-123456789012",
        "mona": "01234567-8901-2345-6789-012345678901"
      }

The keys of this JSON object must be GitHub usernames, while the values must be Clubhouse UUIDs that identify members. Unfortunately, these UUIDs are not exposed on the Clubhouse website; the best way to look them up is to go to the User Directory for your Clubhouse workspace, open the Developer Tools in your browser, find the API request for https://app.clubhouse.io/backend/api/private/members, and examine the API response to find the id for each user. Note that Clubhouse makes a distinction between a User and a Member: you need to look up the UUID for the Member object.

Ignored Users

You can also add a list of GitHub users to ignore for this integration by using the ignored-users input. Multiple users should be separated by commas.

- uses: singingwolfboy/[email protected]
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    clubhouse-token: ${{ secrets.CLUBHOUSE_TOKEN }}
    project-name: Engineering
    ignored-users: hubot, dependabot

Only Users

You can also add a list of GitHub only-users for this integration. This works opposite of the ignored users list above. For example, if you wanted only PRs from a specific GitHub user such as dependabot PRs. Multiple users should be separated by commas.

- uses: singingwolfboy/[email protected]
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    clubhouse-token: ${{ secrets.CLUBHOUSE_TOKEN }}
    project-name: Engineering
    only-users: dependabot

Iteration Support

Clubhouse supports the concept of iterations -- time-boxed periods of development for stories. You can configure this Action to automatically assign the Clubhouse stories it creates to Clubhouse iterations, using GitHub labels and Clubhouse groups to identify the correct iteration to use.

In order to use this feature, this Action makes a few assumptions about the way you use Clubhouse and GitHub:

  • We assume that each team has an associated Clubhouse group, and that Clubhouse iterations are associated with this group.
  • We assume that the correct iteration to use is the most recent in-progress iteration for the group, as determined by the "last updated" time. (However, you may exclude specific iterations by name.)
  • We assume that each team has an associated GitHub label, and that this label is applied to pull requests consistently. (You may do this manually, or use an automated system like the Labeler Action.)

If you want to use this feature, and you have a different workflow that does not match these assumptions, open a GitHub Issue on this repo and let's talk about it! Maybe we can find a way to make this Action support other workflows, as well.

If your workflow is compatible with these assumptions, and you want to use this feature, first you must modify the on section of your config file to include the labeled activity type for the pull_request event. For example:

on:
  pull_request:
    types: [opened, closed, labeled]

Next, provide a JSON-formatted string to the label-iteration-group-map input. This is used to map GitHub labels to Clubhouse groups. Here is an example:

- uses: singingwolfboy/[email protected]
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    clubhouse-token: ${{ secrets.CLUBHOUSE_TOKEN }}
    project-name: Engineering
    label-iteration-group-map: |
      {
        "Team Octocat": {
          "groupId": "12345678-9012-3456-7890-123456789012",
          "excludeName": "Backlog"
        },
        "Unicorns": {
          "groupId": "34567890-1234-5678-9012-345678901234"
        }
      }

In this example, "Team Octocat" and "Unicorns" are labels on GitHub. The "groupId" refers to the ID of the Clubhouse group that are associated with these respective teams. The "excludeName" key is optional; if provided, it is used to exclude specific iterations from consideration.