Skip to content

Commit 724344e

Browse files
committed
docs: add instructions for creating GitHub App + NuxtHub
resolves #15
1 parent 4ba4abc commit 724344e

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,81 @@ pnpm dev --ui-only
3030

3131
This will fire up a dev server but use the remote API to populate it.
3232

33+
## 🚧 Development environment
34+
35+
Setting up a full development environment takes a little extra effort because `unsight.dev` is implemented as a GitHub App. Here's how to set things up.
36+
37+
### Setup
38+
39+
```sh
40+
corepack enable
41+
pnpm i
42+
```
43+
44+
### Start a local tunnel
45+
46+
```sh
47+
npx ngrok http 3000
48+
```
49+
50+
Note the URL under `Forwarding`. It should look something like `https://<GUID>.ngrok-free.app/`. We'll use this in the next step.
51+
52+
### Create a GitHub App for development
53+
54+
1. Navigate to the [GitHub Apps Settings panel](https://github.com/settings/apps) and click 'New GitHub App'.
55+
56+
1. Fill out the form, not changing any defaults:
57+
58+
- **GitHub App name**: Pick any name at all. I normally add `[dev]` at the end of any apps I'm using in development only.
59+
- **Homepage URL**: Doesn't matter; just pick a URL: `https://unsight.dev` would be fine.
60+
- **Setup URL**: `http://localhost:3000`. Tick the 'Redirect on update' checkbox underneath.
61+
- **Webhook URL**: Put the URL you got when starting ngrok, plus `/github/webhook`: `https://<GUID>.ngrok-free.app/github/webhook`. For the 'Secret' field underneath the URL, create a random GUID or password and make a note of it.
62+
- **Repository permissions**: Select 'Issues': 'Read-only'.
63+
- **Subscribe to events**: Select 'Installation target', 'Issues', 'Meta' and 'Repository'.
64+
65+
1. Note down the `App ID:` in your GitHub App settings.
66+
67+
1. Note the 'slug' of your GitHub App. You should be at a URL that looks something like this `https://github.com/settings/apps/unsight-dev`. This last piece (`unsight-dev`) is your app slug.
68+
69+
1. Scroll down to the bottom of the GitHub App setings and click 'Generate a private key'. It should download. Unfortunately this private key is in PKCS#1 format, but we need PKCS#8 in a Cloudflare environment. Run the following command:
70+
71+
```sh
72+
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in <path to the downloaded file>.pem -out <path to your repo>-unsight-pkcs8.key
73+
```
74+
75+
(This outputs a private key file you'll use in the next step.)
76+
77+
### Configure your secrets
78+
79+
Create a `.env` file with the following content (the private key was generated in the last step and can be multi-line, just add a quote before and after it):
80+
81+
```ini
82+
NUXT_WEBHOOK_GITHUB_SECRET_KEY=<random GUID or password you put in the Webhook Secret field when creating your GitHub App>
83+
NUXT_PUBLIC_GITHUB_APP_SLUG=<your app slug you saw in the URL of your GitHub App settings>
84+
NUXT_GITHUB_APP_ID=<GitHub App ID you saw in your GitHub App settings>
85+
NUXT_GITHUB_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
86+
MIIEvcIBADAEBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoABADDbja1oaWVufjdT
87+
...
88+
+qWpvAnlgrGQqvbsuY+XuRnt
89+
-----END PRIVATE KEY-----"
90+
```
91+
92+
### Link your Cloudflare account
93+
94+
We use Workers AI and to do that locally we'll need to hook up to Cloudflare. This project uses [NuxtHub](https://hub.nuxt.com/) to do that. You can get going by creating a free NuxtHub account at https://admin.hub.nuxt.com.
95+
96+
Then run this command in your app directory:
97+
98+
```sh
99+
npx nuxthub link
100+
```
101+
102+
You can select 'Create a new project'. Any storage region should be fine. Your Nuxt dev server should restart, and you'll see a new `NUXT_HUB_PROJECT_KEY` variable in your `.env` file.
103+
104+
You can now visit http://localhost:3000 and click 'Install as a GitHub app'.
105+
106+
You can now directly visit `http://localhost:3000/<your-user-name>/<your-repo>` to view your clusters.
107+
33108
## License
34109

35110
Made with ❤️

0 commit comments

Comments
 (0)