How to have issues and pull requests added to GitHub Projects
When using GitHub Projects, it’s convenient to have issues or pull requests (items) added to the project automatically. There are a few different ways to do it.
Project auto-add
Projects can be configured to auto-add items. You create a workflow, and configure the types of items you’d like added.
GitHub Issues & Projects – March 9th update · GitHub Changelog
Pro: built-in, no code for us to maintain.
Con: You can only choose one source repo for item per workflow. You can however, add up to 20 ‘Add to project’ workflows, one for each source repository.
OSPR bot adding pull requests to repos
The OSPR bot can add pull requests to repos. When it acts on a non-draft pull request, it will add it to projects listed in the catalog.yaml file.
In a repo’s catalog.yaml file, you create an annotation. For example, this will add to the Aperture-Maintained • openedx project:
annotations: # This can be multiple comma-separated projects. openedx.org/add-to-projects: "openedx:23"
More information is in the bot docs: openedx-webhooks/docs/details.rst at master · openedx/openedx-webhooks
Pro: many repos can auto-add to many projects.
Con: only operates on pull requests from outside 2U and Axim; we maintain the code.
Open edX shared workflow
An Open edX shared workflow can add issues to projects: .github/.github/workflows/add-issue-to-a-project.yml at master · openedx/.github
This is almost obsolete: a project workflow does this, but only for one repo. This action can be used in multiple repos to funnel issues from all of them into a project.
You make an action in the source repo to use the workflow, like this:
name: Add new issues to the Security project on: issues: types: [opened] jobs: Add_an_issue_to_project: uses: openedx/.github/.github/workflows/add-issue-to-a-project.yml@master secrets: GITHUB_APP_ID: ${{ secrets.GRAPHQL_AUTH_APP_ID }} GITHUB_APP_PRIVATE_KEY: ${{ secrets.GRAPHQL_AUTH_APP_PEM }} with: PROJECT_NUMBER: 45
Although the action says “issue”, I think it can add pull requests also.
Pro: many repos can auto-add to many projects.
Con: needs secrets management.