Skip to content

Commit

Permalink
feat: added instructions to deploy to Cloudflare Workers
Browse files Browse the repository at this point in the history
  • Loading branch information
whilefoo committed Feb 29, 2024
1 parent 7bd5ff8 commit 54c29c8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,37 @@ The kernel is designed to:
```bash
git clone https://github.com/ubiquity/ubiquibot-kernel
cd ubiquibot-kernel
bun
bun install
bun dev
```

### Deploying to Cloudflare Workers

1. Install dependencies using `bun install`.

2. Create a Github App. Under app settings click `Permissions & events` and make sure the app is subscribed to all events and have these permissions:

```md
Repository permissions:
- Actions: Read & Write
- Contents: Read & Write
- Issues: Read & Write
- Pull Requests: Read & Write
Organization permissions:
- Members: Read only
```

3. Create a Cloudflare account if you don't have one and run `npx wrangler login`.
4. To create a KV namespace run `npx wrangler kv:namespace create PLUGIN_CHAIN_STATE`. Copy the ID to `wrangler.toml` under `[env.dev]`.
5. You can add (env) secrets using `npx wrangler secret put <KEY>`. To add private key run: (replace YOUR_PRIVATE_KEY.PEM with the path to your actual PEM file)
```sh
echo $(openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in YOUR_PRIVATE_KEY.PEM) | npx wrangler secret put PRIVATE_KEY
```
6. To deploy the kernel run `bun run deploy-dev`.
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"format:prettier": "prettier --write .",
"format:cspell": "cspell **/*",
"prepare": "husky install",
"deploy": "wrangler deploy",
"deploy-dev": "wrangler deploy --env dev",
"deploy-production": "wrangler deploy --env production",
"worker": "wrangler dev --port 8787",
"proxy": "tsx src/proxy.ts"
},
Expand Down Expand Up @@ -62,7 +63,7 @@
"prettier": "^3.2.4",
"tsx": "^4.6.2",
"typescript": "^5.0.4",
"wrangler": "^3.23.0"
"wrangler": "^3.30.1"
},
"lint-staged": {
"*.ts": [
Expand All @@ -79,4 +80,4 @@
]
},
"packageManager": "[email protected]"
}
}
5 changes: 4 additions & 1 deletion wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ compatibility_date = "2023-12-06"

[env.dev]
kv_namespaces = [
{ binding = "PLUGIN_CHAIN_STATE", id = "a50ef0a143e449c087b6be613a84e5ba" },
{ binding = "PLUGIN_CHAIN_STATE", id = "4f7aadc56bef41a7ae2cc8c0582320b3" },
]

[env.production]
kv_namespaces = [{ binding = "PLUGIN_CHAIN_STATE", id = "TO_BE_FILLED" }]

# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
# Note: Use secrets to store sensitive data.
# Docs: https://developers.cloudflare.com/workers/platform/environment-variables
Expand Down

0 comments on commit 54c29c8

Please sign in to comment.