You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-25Lines changed: 73 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -34,38 +34,86 @@ Some developers may settle with testing in production as the risks tend to be lo
34
34
35
35
The general overview of what you will need to do:
36
36
37
-
1. Install Postgres. Look online for any help with installing and setting up Postgres (particularly if you need to create a user and set up permissions).
38
-
2. Create a database: `createdb triagebot`
39
-
3. Provide a way for GitHub to access the Triagebot webserver.
40
-
There are various ways to do this (such as placing it behind a proxy, or poking holes in your firewall).
41
-
Or, you can use a service such as https://ngrok.com/ to access on your local dev machine via localhost.
42
-
Installation is fairly simple, though requires setting up a (free) account.
43
-
Run the command `ngrok http 8000` to forward to port 8000 on localhost.
44
-
4. Create a GitHub repo to run some tests on.
45
-
5. Configure the webhook in your GitHub repo.
46
-
I recommend at least skimming the [GitHub webhook documentation](https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks) if you are not familiar with webhooks. In short:
47
-
48
-
1. Go to the settings page.
49
-
2. Go to the webhook section.
50
-
3. Click "Add webhook"
51
-
4. Include the settings:
52
-
53
-
- Payload URL: This is the URL to your Triagebot server, for example http://7e9ea9dc.ngrok.io/github-hook. This URL is displayed when you ran the `ngrok` command above.
54
-
- Content type: application/json
55
-
- Secret: Enter a shared secret (some longish random text)
2.`GITHUB_API_TOKEN`: This is a token needed for Triagebot to send requests to GitHub. Go to GitHub Settings > Developer Settings > Personal Access Token, and create a new token. The `repo` permission should be sufficient.
61
44
If this is not set, Triagebot will also look in `~/.gitconfig` in the `github.oauth-token` setting.
62
-
3.`DATABASE_URL`: This is the URL to the Postgres database. Something like `postgres://eric@localhost/triagebot` should work, replacing `eric` with your username.
45
+
3.`DATABASE_URL`: This is the URL to the database. See [Configuring a database](#configuring-a-database).
63
46
4.`GITHUB_WEBHOOK_SECRET`: Enter the secret you entered in the webhook above.
64
47
5.`RUST_LOG`: Set this to `debug`.
65
48
66
-
7. Run `cargo run --bin triagebot`. This starts the http server listening on port 8000.
67
-
8. Add a `triagebot.toml` file to the main branch of your GitHub repo with whichever services you want to try out.
68
-
9. Try interacting with your repo, such as issuing `@rustbot` commands or interacting with PRs and issues (depending on which services you enabled in `triagebot.toml`). Watch the logs from the server to see what's going on.
49
+
5. Run `cargo run --bin triagebot`. This starts the http server listening for webhooks on port 8000.
50
+
6. Add a `triagebot.toml` file to the main branch of your GitHub repo with whichever services you want to try out.
51
+
7. Try interacting with your repo, such as issuing `@rustbot` commands or interacting with PRs and issues (depending on which services you enabled in `triagebot.toml`). Watch the logs from the server to see what's going on.
52
+
53
+
### Configure a database
54
+
55
+
To use Postgres, you will need to install it and configure it:
56
+
57
+
1. Install Postgres. Look online for any help with installing and setting up Postgres (particularly if you need to create a user and set up permissions).
58
+
2. Create a database: `createdb triagebot`
59
+
3. In the `.env` file, set the `DATABASE_URL`:
60
+
61
+
```sh
62
+
DATABASE_URL=postgres://eric@localhost/triagebot
63
+
```
64
+
65
+
replacing `eric` with the username on your local system.
66
+
67
+
### Configure webhook forwarding
68
+
69
+
I recommend at least skimming the [GitHub webhook documentation](https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks) if you are not familiar with webhooks.
70
+
In order for GitHub's webhooks to reach your triagebot server, you'll need to figure out some way to route them to your machine.
71
+
There are various options on how to do this.
72
+
You can poke holes into your firewall or use a proxy, but you shouldn't expose your machine to the the internet.
73
+
There are various services which help with this problem.
74
+
These generally involve running a program on your machine that connects to an external server which relays the hooks into your machine.
75
+
There are several to choose from:
76
+
77
+
*[gh webhook](#gh-webhook) — This is a GitHub-native service. This is the easiest to use.
78
+
*[ngrok](#ngrok) — This is pretty easy to use, but requires setting up a free account.
79
+
*<https://smee.io/> — This is another service recommended by GitHub.
80
+
*<https://localtunnel.github.io/www/> — This is another service recommended by GitHub.
81
+
82
+
#### gh webhook
83
+
84
+
The [`gh` CLI](https://github.com/cli/cli) is the official CLI tool which I highly recommend getting familiar with.
85
+
There is an official extension which provides webhook forwarding and also takes care of all the configuration.
86
+
See [cli/gh-webhook](https://docs.github.com/en/developers/webhooks-and-events/webhooks/receiving-webhooks-with-the-github-cli) for more information on installing it.
87
+
88
+
This is super easy to use, and doesn't require manually configuring webhook settings.
Where the value in `--secret` is the secret value you place in `GITHUB_WEBHOOK_SECRET` in the `.env` file, and `--repo` is the repo you want to test against.
97
+
98
+
#### ngrok
99
+
100
+
The following is an example of using <https://ngrok.com/> to provide webhook forwarding.
101
+
You need to sign up for a free account, and also deal with configuring the GitHub webhook settings.
102
+
103
+
1. Install ngrok.
104
+
2. Run `ngrok http 8000`. This will forward webhook events to localhost on port 8000.
105
+
3. Configure GitHub webhooks in the test repo you created.
106
+
In short:
107
+
108
+
1. Go to the settings page for your GitHub repo.
109
+
2. Go to the webhook section.
110
+
3. Click "Add webhook"
111
+
4. Include the settings:
112
+
113
+
* Payload URL: This is the URL to your Triagebot server, for example http://7e9ea9dc.ngrok.io/github-hook. This URL is displayed when you ran the `ngrok` command above.
114
+
* Content type: application/json
115
+
* Secret: Enter a shared secret (some longish random text)
0 commit comments