Skip to content

Commit

Permalink
Merge pull request #118 from ubiquity-os/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
gentlementlegen authored Sep 27, 2024
2 parents 1ea138d + 89c9ad2 commit a9c965d
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
WEBHOOK_PROXY_URL=https://smee.io/new
WEBHOOK_SECRET=xxxxxx
APP_WEBHOOK_SECRET=xxxxxx
APP_ID=123456
2 changes: 1 addition & 1 deletion .github/workflows/bun-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
NODE_ENV: "test"
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
APP_WEBHOOK_SECRET: ${{ secrets.APP_WEBHOOK_SECRET }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
build:
runs-on: ubuntu-22.04

environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }}

steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -46,15 +48,14 @@ jobs:
- uses: cloudflare/wrangler-action@v3
id: wrangler_deploy
with:
wranglerVersion: "3.63.1"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
APP_ID
APP_PRIVATE_KEY
WEBHOOK_SECRET
APP_WEBHOOK_SECRET
env:
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
APP_WEBHOOK_SECRET: ${{ secrets.APP_WEBHOOK_SECRET }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

### ⚠ BREAKING CHANGES

* renamed PRIVATE_KEY to APP_PRIVATE_KEY, WEBHOOK_SECRET optional and removed WEBHOOK_PROXY_URL
* renamed PRIVATE_KEY to APP_PRIVATE_KEY, APP_WEBHOOK_SECRET optional and removed WEBHOOK_PROXY_URL
* bumped eslint to v9
* removed GitHub type from the configuration as it is deduced using the plugin element string

Expand Down Expand Up @@ -178,7 +178,7 @@
* remove unused import ([c96e2a7](https://github.com/ubiquity/ubiquibot-kernel/commit/c96e2a707743616df666d27974bacd99a4abe5ba))
* removed GitHub type from the configuration as it is deduced using the plugin element string ([570b68e](https://github.com/ubiquity/ubiquibot-kernel/commit/570b68e18639e9c38a90872cfb8cbfbbdf661481))
* rename pull_request_template ([8aa986e](https://github.com/ubiquity/ubiquibot-kernel/commit/8aa986e6885173d56f628ee6d887d3619a19407c))
* renamed PRIVATE_KEY to APP_PRIVATE_KEY, WEBHOOK_SECRET optional and removed WEBHOOK_PROXY_URL ([f71043e](https://github.com/ubiquity/ubiquibot-kernel/commit/f71043e7f1fe0277591e0682e2ff3340e206e0b9))
* renamed PRIVATE_KEY to APP_PRIVATE_KEY, APP_WEBHOOK_SECRET optional and removed WEBHOOK_PROXY_URL ([f71043e](https://github.com/ubiquity/ubiquibot-kernel/commit/f71043e7f1fe0277591e0682e2ff3340e206e0b9))
* resolve conflicts ([403232c](https://github.com/ubiquity/ubiquibot-kernel/commit/403232cdc4aee6260bf968875d90edf211a6c961))
* return default conf on custom conf fail ([207f68e](https://github.com/ubiquity/ubiquibot-kernel/commit/207f68e5e8ff2c018173636035cdf8bc3316f0c6))
* spell ([b40750f](https://github.com/ubiquity/ubiquibot-kernel/commit/b40750ffa37ec668eb1dd0c2ee7fd0525c66f73f))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The kernel is designed to:

**Note:** Replace `YOUR_APP_PRIVATE_KEY.PEM` with the path to your actual PEM file when running the command.

- **`WEBHOOK_SECRET`**
- **`APP_WEBHOOK_SECRET`**
Set this value in both your GitHub App settings and here.

- **`APP_ID`**
Expand Down
Binary file modified bun.lockb
Binary file not shown.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
"yaml": "2.4.5"
},
"devDependencies": {
"@swc/core": "1.6.5",
"@swc/jest": "0.2.36",
"tsup": "8.1.0",
"@jest/globals": "29.7.0",
"@types/jest": "29.5.12",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"@swc/core": "1.6.5",
"@swc/jest": "0.2.36",
"tsup": "8.1.0",
"@jest/globals": "29.7.0",
"@types/jest": "29.5.12",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"@cloudflare/workers-types": "4.20240117.0",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
Expand Down Expand Up @@ -103,7 +103,7 @@
"tsx": "4.16.2",
"typescript": "5.5.3",
"typescript-eslint": "7.16.0",
"wrangler": "3.64.0"
"wrangler": "3.78.10"
},
"lint-staged": {
"*.ts": [
Expand Down
2 changes: 1 addition & 1 deletion src/github/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp
// invoke the first plugin in the chain
const { plugin, with: settings } = pluginChain.uses[0];
const isGithubPluginObject = isGithubPlugin(plugin);
console.log(`Calling handler for event ${event.name}`);
console.log(`Calling handler ${JSON.stringify(plugin)} for event ${event.name}`);

const stateId = crypto.randomUUID();

Expand Down
4 changes: 2 additions & 2 deletions src/github/types/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Type as T, type Static } from "@sinclair/typebox";

export const envSchema = T.Object({
WEBHOOK_SECRET: T.String({ minLength: 1 }),
APP_WEBHOOK_SECRET: T.String({ minLength: 1 }),
APP_ID: T.String({ minLength: 1 }),
APP_PRIVATE_KEY: T.String({ minLength: 1 }),
});
Expand All @@ -15,7 +15,7 @@ declare global {
namespace NodeJS {
interface ProcessEnv {
APP_ID: string;
WEBHOOK_SECRET: string;
APP_WEBHOOK_SECRET: string;
APP_PRIVATE_KEY: string;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
const signatureSha256 = getSignature(request);
const id = getId(request);
const eventHandler = new GitHubEventHandler({
webhookSecret: env.WEBHOOK_SECRET,
webhookSecret: env.APP_WEBHOOK_SECRET,
appId: env.APP_ID,
privateKey: env.APP_PRIVATE_KEY,
pluginChainState: new CloudflareKv(env.PLUGIN_CHAIN_STATE),
Expand Down
4 changes: 2 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("Worker tests", () => {
const req = new Request("http://localhost:8080");
const consoleSpy = jest.spyOn(console, "error").mockImplementation(() => jest.fn());
const res = await worker.fetch(req, {
WEBHOOK_SECRET: "",
APP_WEBHOOK_SECRET: "",
APP_ID: "",
APP_PRIVATE_KEY: "",
PLUGIN_CHAIN_STATE: {} as KVNamespace,
Expand All @@ -76,7 +76,7 @@ describe("Worker tests", () => {
},
});
const res = await worker.fetch(req, {
WEBHOOK_SECRET: "webhook-secret",
APP_WEBHOOK_SECRET: "webhook-secret",
APP_ID: "app-id",
APP_PRIVATE_KEY: "private-key",
PLUGIN_CHAIN_STATE: {} as KVNamespace,
Expand Down
4 changes: 4 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ compatibility_flags = [ "nodejs_compat" ]
binding = "PLUGIN_CHAIN_STATE"
id = "TO_BE_DEFINED"

# Enables Cloudflare Worker Logs
[observability]
enabled = true

# 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 a9c965d

Please sign in to comment.