Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github - Auto assign Issue to Project

I would like to Auto Assign an issue to a project in Github. Basically automate the below screenshot for every issue automatically opened. Any ideas?

enter image description here

like image 331
DottoreM Avatar asked Jun 23 '20 08:06

DottoreM


People also ask

Is it possible to assign GitHub issues to specific users?

However, GitHub apps are essentially deprecated at this point, as they've been superseded by GitHub actions. In this post I show how you can install a GitHub action workflow into your repository that automatically assigns new issues to specific users. Why do you need this?

How do I add issues and pull requests to projects?

You can add issues and pull requests to a project board in the form of cards and triage them into columns. Note: Projects (beta), the all-new projects experience, is now available. For more information about projects (beta), see " About projects (beta) ." You can add issue or pull request cards to your project board by:

What are GitHub actions and how to use them?

I'm not going to go into detail about GitHub actions here, but in short, GitHub actions allows you to run code when an event happens in your GitHub repository. One of the most common events is for a push to your repository, so you can use GitHub actions for running continuous integration builds of your application.

How do I test an issue assignment workflow?

This is an easy one to test, simply create a test issue in your repository! When you do, you won't see the issue assigned immediately, but if you check the Actions tab, you'll see that the "Issue assignment" workflow is running: After a few seconds or so, you should see the workflow has turned green.


4 Answers

You can use create-or-update-project-card to achieve this.

on:
  issues:
    types: [opened]
jobs:
  createCard:
    runs-on: ubuntu-latest
    steps:
      - name: Create or Update Project Card
        uses: peter-evans/create-or-update-project-card@v1
        with:
          project-name: My project
          column-name: My column
like image 115
peterevans Avatar answered Oct 20 '22 01:10

peterevans


For the new beta projects, there's now an official action to add issues and pull requests: actions/add-to-project. It's "in beta, however the API is stable".

Using the action looks roughly like

      - uses: actions/add-to-project@main
        with:
          project-url: https://github.com/orgs/<orgName>/projects/<projectNumber>
          github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
          labeled: bug, needs-triage
          label-operator: OR

where the token requires repo and project scopes (as of v0.1.0).

like image 30
Benjamin W. Avatar answered Oct 20 '22 00:10

Benjamin W.


There is an app Project Bot to automate this because right now it seems like it is not possible to do so with just the GitHub project configuration.

Here is the Project Bot description from it's repo

This bot will automatically add new Issues or Pull Requests to a Project board based on specially formatted Cards in each Column of a Project. It also allows you to customize the rules for moving Issues between Columns.

Here is the project-bot repo: https://github.com/philschatz/project-bot

I hope it helps!

like image 29
reymon359 Avatar answered Oct 19 '22 23:10

reymon359


I managed to make it work using this workflow.

like image 23
DottoreM Avatar answered Oct 20 '22 00:10

DottoreM