-
Notifications
You must be signed in to change notification settings - Fork 19
feat: support personal account #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kholisrag
wants to merge
2
commits into
hostinger:main
Choose a base branch
from
kholisrag:feat/support-personal-accounts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # GitHub App | ||
|
|
||
| Fireactions authenticates with GitHub as a [GitHub App](https://docs.github.com/en/apps/creating-github-apps). The App is | ||
| the only credential Fireactions needs: it creates just-in-time (JIT) runner registrations before starting a Firecracker | ||
| VM, and deletes the runner from GitHub after the VM exits. | ||
|
|
||
| The App is configured in the `github` section of the configuration file: | ||
|
|
||
| ```yaml | ||
| github: | ||
| app_id: 12345 | ||
| app_private_key: | | ||
| -----BEGIN RSA PRIVATE KEY----- | ||
| ... | ||
| -----END RSA PRIVATE KEY----- | ||
| ``` | ||
|
|
||
| Which permissions the App needs depends on the [runner scope](concepts.md#runner-scope) of your pools. | ||
|
|
||
| ## Permissions | ||
|
|
||
| ### Organization scoped pools | ||
|
|
||
| For pools that set `runner.organization`, grant the following **organization permission**: | ||
|
|
||
| | Permission | Access | | ||
| |---------------------|------------------| | ||
| | Self-hosted runners | Read and write | | ||
|
|
||
| This is the permission that covers `POST /orgs/{org}/actions/runners/generate-jitconfig` and | ||
| `DELETE /orgs/{org}/actions/runners/{runner_id}`. The organization `Administration` permission does **not** grant access | ||
| to these endpoints, so granting it instead won't work. | ||
|
|
||
| No repository permissions are needed: runners are registered with the organization itself, not with any of its | ||
| repositories. | ||
|
|
||
| ### Repository scoped pools | ||
|
|
||
| For pools that set `runner.repository`, grant the following **repository permissions**: | ||
|
|
||
| | Permission | Access | | ||
| |----------------|-----------------------------------| | ||
| | Administration | Read and write | | ||
| | Metadata | Read-only (granted automatically) | | ||
|
|
||
| `Administration` covers `POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig` and | ||
| `DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}`. GitHub grants `Metadata: Read-only` automatically as soon as | ||
| any repository permission is selected. | ||
|
|
||
| Repository scoped pools are the only option for personal (user) accounts, which can't have organization runners. They | ||
| work for organization owned repositories too. | ||
|
|
||
| !!! note | ||
| A single App can serve both kinds of pools. Grant the organization `Self-hosted runners` permission and the | ||
| repository `Administration` permission if you run organization scoped and repository scoped pools side by side. | ||
|
|
||
| ### Not required | ||
|
|
||
| Fireactions does not need any of the following, and you can leave them unset: | ||
|
|
||
| - **Webhooks and webhook events.** Fireactions keeps each pool at its configured number of replicas on its own and does | ||
| not consume `workflow_job` or any other event, so the App needs no webhook URL and no event subscriptions. | ||
| - **The `Actions` permission.** Fireactions never reads or writes workflow runs, jobs or artifacts. | ||
| - **Account (user) permissions.** | ||
|
|
||
| ## Creating and installing the App | ||
|
|
||
| The App can be owned by an organization or by a personal account. Ownership only decides who administers the App; what | ||
| matters for Fireactions is the account the App is *installed* on. | ||
|
|
||
| 1. Create the App: | ||
| - **Organization owned:** `https://github.com/organizations/<ORG>/settings/apps/new` | ||
| - **Personal account owned:** `https://github.com/settings/apps/new` | ||
| 2. Set a name and a homepage URL. Uncheck **Active** under **Webhook** — Fireactions doesn't use webhooks. | ||
| 3. Under **Permissions**, grant the permissions for your runner scope from the tables above. | ||
| 4. Create the App, then note the **App ID** and generate a **private key**. The downloaded `.pem` file is what goes into | ||
| `github.app_private_key`. | ||
| 5. Install the App: | ||
| - **On an organization** (for organization scoped pools): **Install App** → choose the organization. | ||
| - **On a personal account** (for repository scoped pools): **Install App** → choose your account, then | ||
| **Only select repositories** and pick the repositories your pools register runners with. | ||
|
|
||
| !!! warning | ||
| Changing an App's permissions after installation requires accepting the new permissions on the installation before | ||
| they take effect. If Fireactions starts failing with `403` errors after a permission change, check the installation | ||
| settings page for a pending request. | ||
|
|
||
| ## Installation ID | ||
|
|
||
| Fireactions needs the ID of the App installation on the account owning the runners. It looks the ID up automatically | ||
| using the App's own JWT — `GET /orgs/{org}/installation` for organization scoped pools and | ||
| `GET /repos/{owner}/{repo}/installation` for repository scoped pools. Neither call needs an installation permission, so | ||
| in most setups nothing else is required. | ||
|
|
||
| Set `runner.installation_id` to skip the lookup: | ||
|
|
||
| ```yaml | ||
| runner: | ||
| repository: octocat/hello-world | ||
| installation_id: 12345678 | ||
| ``` | ||
|
|
||
| You can find the ID in the URL of the installation's settings page: | ||
|
|
||
| - Organization: **Settings** → **GitHub Apps** → **Configure**, the URL ends in | ||
| `/organizations/<ORG>/settings/installations/<INSTALLATION_ID>` | ||
| - Personal account: **Settings** → **Applications** → **Configure**, the URL ends in | ||
| `/settings/installations/<INSTALLATION_ID>` | ||
|
|
||
| Or via the API, authenticating with the App's JWT: | ||
|
|
||
| ```bash | ||
| gh api /repos/<OWNER>/<REPOSITORY>/installation --jq .id | ||
| ``` | ||
|
kholisrag marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## API calls Fireactions makes | ||
|
|
||
| | Endpoint | Authenticated as | Permission | | ||
| |-------------------------------------------------------------|------------------|-------------------------------------------| | ||
| | `GET /orgs/{org}/installation` | App (JWT) | None | | ||
| | `GET /repos/{owner}/{repo}/installation` | App (JWT) | None | | ||
| | `POST /orgs/{org}/actions/runners/generate-jitconfig` | Installation | Organization `Self-hosted runners: write` | | ||
| | `DELETE /orgs/{org}/actions/runners/{runner_id}` | Installation | Organization `Self-hosted runners: write` | | ||
| | `POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig` | Installation | Repository `Administration: write` | | ||
| | `DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}` | Installation | Repository `Administration: write` | | ||
|
|
||
| The organization endpoints are only used by pools with `runner.organization` set, the repository endpoints only by pools | ||
| with `runner.repository` set. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.