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.

  1. Create a new app with repo read, project write permissions in your org
    1. Go to your organization’s “new app” page, e.g. https://github.com/organizations/mark-wiemer-org/settings/apps/new/
    2. Choose any name, description, and homepage URL.
    3. Disable webhook activation.
    4. For repository permissions, choose “issues: read-only” and “PRs: read-only”
    5. For organization permissions, choose “projects: read and write”
    6. “Where can this GitHub App be installed?” Only on this account.
  2. Generate and save the private key for the app
  3. Install the app to your organization account (e.g. https://github.com/organizations/mark-wiemer-org/settings/apps/mark-wiemer-app/installations)
  4. In your repo, add the secrets
    1. Go to e.g. https://github.com/mark-wiemer/hello-hello/settings/secrets/actions
    2. APP_PRIVATE_KEY is the saved private key, of the form:
      -----BEGIN RSA PRIVATE KEY-----
      abcabc123123abcabc...
      -----END RSA PRIVATE KEY-----
      (no trailing newline)
    3. APP_CLIENT_ID comes from e.g. https://github.com/organizations/mark-wiemer-org/settings/apps/mark-wiemer-app. This does not have to be a secret.
  5. 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.

Just for Mark’s reference.

See also GitHub - markwiemer.com