Skip to content

Commit b3e2c58

Browse files
Update docs
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
1 parent 27e74ef commit b3e2c58

File tree

3 files changed

+186
-131
lines changed

3 files changed

+186
-131
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ The ```GARM``` configuration is a simple ```toml```. The sample config file in [
3535
* [The default section](/doc/config_default.md)
3636
* [Logging](/doc/config_logging.md)
3737
* [Database](/doc/database.md)
38-
* [Github credentials](/doc/github_credentials.md)
3938
* [Providers](/doc/providers.md)
4039
* [Metrics](/doc/config_metrics.md)
4140
* [JWT authentication](/doc/config_jwt_auth.md)

doc/github_credentials.md

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1-
# Configuring github credentials
1+
# Configuring github endpoints and credentials
22

3-
The ```github``` config section holds credentials and API endpoint information for accessing the GitHub APIs. Credentials are tied to the instance of GitHub you're using. Whether you're using [github.com](https://github.com) or your own deployment of GitHub Enterprise server, this section is how ```garm``` knows where it should create the runners.
3+
Starting with version `v0.1.5`, GARM saves github endpoints and github credentials in the database.
44

5-
Tying the API endpoint info to the credentials allows us to use the same ```garm``` installation with both [github.com](https://github.com) and private deployments. All you have to do is to add the needed endpoint info (see bellow).
5+
<!-- TOC -->
6+
7+
- [Configuring github endpoints and credentials](#configuring-github-endpoints-and-credentials)
8+
- [Listing GitHub endpoints](#listing-github-endpoints)
9+
- [Adding GitHub credentials](#adding-github-credentials)
10+
- [Listing GitHub credentials](#listing-github-credentials)
11+
- [Deleting GitHub credentials](#deleting-github-credentials)
12+
13+
<!-- /TOC -->
14+
## Listing GitHub endpoints
15+
16+
To list the available GitHub endpoints, you can use the following command:
17+
18+
```bash
19+
ubuntu@garm:~/garm$ garm-cli github endpoint list
20+
+------------+--------------------------+-------------------------------+
21+
| NAME | BASE URL | DESCRIPTION |
22+
+------------+--------------------------+-------------------------------+
23+
| github.com | https://github.com | The github.com endpoint |
24+
+------------+--------------------------+-------------------------------+
25+
| example | https://ghes.example.com | Just an example ghes endpoint |
26+
+------------+--------------------------+-------------------------------+
27+
```
28+
29+
## Adding GitHub credentials
630

731
GARM has the option to use both [Personal Access Tokens (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) or a [GitHub App](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app).
832

@@ -28,55 +52,44 @@ If you plan to use github apps, you'll need to select the following permissions:
2852

2953
**Note** :warning:: Github Apps are not available at the enterprise level.
3054

31-
The resulting credentials (app or PAT) must be configured in the ```[[github]]``` section of the config. Sample as follows:
32-
33-
```toml
34-
# This is a list of credentials that you can define as part of the repository
35-
# or organization definitions. They are not saved inside the database, as there
36-
# is no Vault integration (yet). This will change in the future.
37-
# Credentials defined here can be listed using the API. Obviously, only the name
38-
# and descriptions are returned.
39-
[[github]]
40-
name = "gabriel"
41-
description = "github token or user gabriel"
42-
# This is the type of authentication to use. It can be "pat" or "app"
43-
auth_type = "pat"
44-
[github.pat]
45-
# This is a personal token with access to the repositories and organizations
46-
# you plan on adding to garm. The "workflow" option needs to be selected in order
47-
# to work with repositories, and the admin:org needs to be set if you plan on
48-
# adding an organization.
49-
oauth2_token = "super secret token"
50-
[github.app]
51-
# This is the app_id of the GitHub App that you want to use to authenticate
52-
# with the GitHub API.
53-
# This needs to be changed
54-
app_id = 1
55-
# This is the private key path of the GitHub App that you want to use to authenticate
56-
# with the GitHub API.
57-
# This needs to be changed
58-
private_key_path = "/etc/garm/yourAppName.2024-03-01.private-key.pem"
59-
# This is the installation_id of the GitHub App that you want to use to authenticate
60-
# with the GitHub API.
61-
# This needs to be changed
62-
installation_id = 99
63-
# base_url (optional) is the URL at which your GitHub Enterprise Server can be accessed.
64-
# If these credentials are for github.com, leave this setting blank
65-
base_url = "https://ghe.example.com"
66-
# api_base_url (optional) is the base URL where the GitHub Enterprise Server API can be accessed.
67-
# Leave this blank if these credentials are for github.com.
68-
api_base_url = "https://ghe.example.com"
69-
# upload_base_url (optional) is the base URL where the GitHub Enterprise Server upload API can be accessed.
70-
# Leave this blank if these credentials are for github.com, or if you don't have a separate URL
71-
# for the upload API.
72-
upload_base_url = "https://api.ghe.example.com"
73-
# ca_cert_bundle (optional) is the CA certificate bundle in PEM format that will be used by the github
74-
# client to talk to the API. This bundle will also be sent to all runners as bootstrap params.
75-
# Use this option if you're using a self signed certificate.
76-
# Leave this blank if you're using github.com or if your certificate is signed by a valid CA.
77-
ca_cert_bundle = "/etc/garm/ghe.crt"
55+
To add a new GitHub credential, you can use the following command:
56+
57+
```bash
58+
garm-cli github credentials add \
59+
--name gabriel \
60+
--description "GitHub PAT for user gabriel" \
61+
--auth-type pat \
62+
--pat-oauth-token gh_theRestOfThePAT \
63+
--endpoint github.com
64+
```
65+
66+
To add a new GitHub App credential, you can use the following command:
67+
68+
```bash
69+
garm-cli github credentials add \
70+
--name gabriel_app \
71+
--description "Github App with access to repos" \
72+
--endpoint github.com \
73+
--auth-type app \
74+
--app-id 1 \
75+
--app-installation-id 99 \
76+
--private-key-path $HOME/yourAppName.2024-03-01.private-key.pem
77+
```
78+
79+
All sensitive data is encrypted at rest. The API will not return any sensitive info.
80+
81+
## Listing GitHub credentials
82+
83+
To list the available GitHub credentials, you can use the following command:
84+
85+
```bash
86+
garm-cli github credentials list
7887
```
7988

80-
The double parenthesis means that this is an array. You can specify the ```[[github]]``` section multiple times, with different tokens from different users, or with different access levels. You will then be able to list the available credentials using the API, and reference these credentials when adding repositories or organizations.
89+
## Deleting GitHub credentials
90+
91+
To delete a GitHub credential, you can use the following command:
8192

82-
The API will only ever return the name and description to the API consumer.
93+
```bash
94+
garm-cli github credentials delete <CREDENTIAL_ID>
95+
```

0 commit comments

Comments
 (0)