GitHub Apps
I’m learning a new thing!
Automatically adding issues and PRs to a project
In some scenarios, connecting a repo to a project can be complex. The best workflow I’ve found has been using a GitHub App attached to an organization.
- Create a new app with repo read, project write permissions in your org
- Go to your organization’s “new app” page, e.g. https://github.com/organizations/mark-wiemer-org/settings/apps/new/
- Choose any name, description, and homepage URL.
- Disable webhook activation.
- For repository permissions, choose “issues: read-only” and “PRs: read-only”
- For organization permissions, choose “projects: read and write”
- “Where can this GitHub App be installed?” Only on this account.
- Generate and save the private key for the app
- Install the app to your organization account (e.g. https://github.com/organizations/mark-wiemer-org/settings/apps/mark-wiemer-app/installations)
- In your repo, add the secrets
- Go to e.g. https://github.com/mark-wiemer/hello-hello/settings/secrets/actions
APP_PRIVATE_KEYis the saved private key, of the form:
(no trailing newline)-----BEGIN RSA PRIVATE KEY----- abcabc123123abcabc... -----END RSA PRIVATE KEY-----APP_CLIENT_IDcomes from e.g. https://github.com/organizations/mark-wiemer-org/settings/apps/mark-wiemer-app. This does not have to be a secret.
- Add the workflow to your repo, ref https://github.com/mark-wiemer/hello-hello/blob/main/.github/workflows/_global-add-to-project.yml
Things should just work!
Note that auto-adding PRs from forks will fail as forks don’t have access to repo secrets. I suggest leaving those out and tracking them via backing issues or notifications, if possible.
Private links
Just for Mark’s reference.
- hello-hello secrets - GitHub
- Link the installed app to my main repo
- Settings > Apps > mark-wiemer-app - GitHub
- Create permission requests
- Settings > Installations - GitHub
- Accept or reject permission requests
See also GitHub - markwiemer.com