DEV Community

Play Button Pause Button
Brian Douglas for GitHub

Posted on • Updated on

Assigning new contributors to issues using GitHub Actions

When most folks consider GitHub Actions, they continuous integration or continuous delivery, a portion of the Actions I use in my workflows focus on the webhook events related to issue comments.

Now and again, I get a user interested in contributing to my projects, and I'm always looking to make sure every contributor can have a tremendous first contributor experience.

There have been times when my project gets more attention than normal, and I'll have multiple users trying to contribute to the same issue. So to prevent this, I provide context and steps for contributing inside my CONTRIBUTING.MD. Inside this doc, there are detailed instructions on how to take an issue and claim it.

// https://github.com/open-sauced/open-sauced/blob/main/.github/workflows/assign-yourself.yml

name: Assign
on:
  issue_comment:
    types: [created, edited] // action runs on new and edited issue comments

jobs:
  one:
    runs-on: ubuntu-latest
    steps:
      # .take in an issue comment. 
      - name: take an issue
        uses: bdougie/take-action@main
        env:
          GITHUB_TOKEN: ${{ github.token }}
Enter fullscreen mode Exit fullscreen mode

Learn how I build this action on YouTube, Build GitHub Actions with a Docker Container

The way I power this feature is through a GitHub Action. Not allow any GitHub user the ability to assign an issue is an intentional security precaution. Only GitHub Organization members can assign themselves to issues.

Screen Shot 2021-02-05 at 1.19.40 PM

This can be a blocker during times like Hacktoberfest when you want to contribute to an issue, but you can't assign yourself as a non-org member. So I've taken the time to create an action called take-action. This is an Action. I've leveraged in my repo to provide the ability to have folks take action on issues.

GitHub logo bdougie / take-action

This is an action to assign yourself to an issue for a repo you are not a contributor to.

Take Action

This is an action to assign yourself to an issue for a repo you are not a contributor to.

Usage

This GitHub Action lets a prospective contributor assign themselves to an issue, and optionally leaves a comment on the issue.

  • messageThe message to display to the user once they have assigned themselves to an issue.
  • triggerThe string that take action will search for in the comment body to activate the action.

Setup

This GitHub Action can be optionally configured with a message to the prospective contributor.

The Action must be given a PAT with permission to write to Issues in the token input.

The easiest way is to use the built-in ${{ secrets.GITHUB_TOKEN }} for authentication (as per the example below), but you'll need to ensure you've appropriately set the permissions for the GitHub Token so that your workflow can update Issues.

To do this, follow…

Now most Actions, including this one, are open source. So if you're interested in learning how to accomplish this, contributions are welcomed. Now any first-time contributor can check the assignee field to see what's ups for grabs. No more commenting on tasks to ask if this problem has been solved or currently being worked on.

This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev.

Top comments (0)