|
| 1 | +## Setting up a GitHub App for Runner Registration |
| 2 | + |
| 3 | +You can create a GitHub App for your user account, or any organization. |
| 4 | + |
| 5 | +The following app permissions are required for each supported type of runner: |
| 6 | + |
| 7 | +_Note: Links are provided further down to create an app for your logged in user account or an organization with the permissions for all runner types set in each link's query string_ |
| 8 | + |
| 9 | +**Required Permissions for Repository Runners:**<br /> |
| 10 | +**Repository Permissions** |
| 11 | + |
| 12 | +* Actions (read) |
| 13 | +* Administration (read / write) |
| 14 | +* Metadata (read) |
| 15 | + |
| 16 | +**Required Permissions for Organization Runners:**<br /> |
| 17 | +**Repository Permissions** |
| 18 | + |
| 19 | +* Actions (read) |
| 20 | +* Metadata (read) |
| 21 | + |
| 22 | +**Organization Permissions** |
| 23 | +* Self-hosted runners (read / write) |
| 24 | + |
| 25 | + |
| 26 | +_Note: All API routes mapped to their permissions can be found [here](https://docs.github.com/en/rest/reference/permissions-required-for-github-apps) if you wish to review_ |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +**Setup Steps** |
| 31 | + |
| 32 | +If you want to create a GitHub App for your account, open the following link to the creation page, enter any unique name in the "GitHub App name" field, and hit the "Create GitHub App" button at the bottom of the page. |
| 33 | + |
| 34 | +<!-- markdown-link-check-disable-next-line --> |
| 35 | +- [Create GitHub Apps on your account](https://github.com/settings/apps/new?url=https://github.com/redhat-actions/openshift-actions-runners&webhook_active=false&public=false&administration=write&actions=read) |
| 36 | + |
| 37 | +If you want to create a GitHub App for your organization, replace the `:org` part of the following URL with your organization name before opening it. Then enter any unique name in the "GitHub App name" field, and hit the "Create GitHub App" button at the bottom of the page to create a GitHub App. |
| 38 | + |
| 39 | +<!-- markdown-link-check-disable-next-line --> |
| 40 | +- [Create GitHub Apps on your organization](https://github.com/organizations/:org/settings/apps/new?url=https://github.com/redhat-actions/openshift-actions-runners&webhook_active=false&public=false&administration=write&organization_self_hosted_runners=write&actions=read) |
| 41 | + |
| 42 | +You will see an *App ID* on the page of the GitHub App you created. You will need the value of this App ID later. |
| 43 | + |
| 44 | +Download the private key file by pushing the "Generate a private key" button at the bottom of the GitHub App page. This file will also be used later. |
| 45 | + |
| 46 | +Go to the "Install App" tab on the left side of the page and install the GitHub App that you created for your account or organization. |
| 47 | + |
| 48 | +When the installation is complete, you will be taken to a URL in one of the following formats. The number at the end of the URL will be used as the Installation ID later. |
| 49 | + |
| 50 | +For example, if the URL ends in `settings/installations/12345`, then the Installation ID is `12345`. |
| 51 | + |
| 52 | +- `https://github.com/settings/installations/${INSTALLATION_ID}` |
| 53 | +- `https://github.com/organizations/eventreactor/settings/installations/${INSTALLATION_ID}` |
| 54 | + |
| 55 | +### Running Locally with GitHub App Authentication |
| 56 | + |
| 57 | +You need to set the `GITHUB_APP_ID`, `GITHUB_APP_INSTALL_ID`, and `GITHUB_APP_PEM` env variables and pass them to your container. |
| 58 | + |
| 59 | +The easiest way to get the private key in the correct form is to copy paste it into the environment variable. Newlines must be preserved. |
| 60 | + |
| 61 | +To launch and connect a runner to `redhat-actions/openshift-actions-runner` with the labels `local` and `podman`: |
| 62 | + |
| 63 | +```sh |
| 64 | +podman run \ |
| 65 | + --env GITHUB_APP_ID \ |
| 66 | + --env GITHUB_APP_INSTALL_ID \ |
| 67 | + --env GITHUB_APP_PEM \ |
| 68 | + --env GITHUB_OWNER=redhat-actions \ |
| 69 | + --env GITHUB_REPOSITORY=openshift-actions-runner \ |
| 70 | + --env RUNNER_LABELS="local,podman" \ |
| 71 | + quay.io/redhat-github-actions/runner:latest |
| 72 | +``` |
0 commit comments