Skip to content

Commit 225c85d

Browse files
Update dependency @notionhq/client to v2 (#40)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dotan Simha <[email protected]>
1 parent 5e2baf6 commit 225c85d

File tree

12 files changed

+4966
-13053
lines changed

12 files changed

+4966
-13053
lines changed

.github/workflows/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v3
1414
- uses: actions/setup-node@v3
1515
with:
16-
node-version: 16
16+
node-version: 18
1717
- run: npm install
1818
- name: Publish
1919
uses: cloudflare/[email protected]

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,32 @@ To remove a public discussion:
4747
## Getting started (development)
4848

4949
1. Clone this repo
50-
2. Make sure to install Wrangler CLI: https://developers.cloudflare.com/workers/wrangler/get-started/
50+
2. Make sure to install Wrangler CLI: https://developers.cloudflare.com/workers/wrangler/get-started/ and use `pnpm`
5151
3. Create a Notion integration and get your Notion token (see https://www.notion.so/my-integrations). Use the token as `NOTION_TOKEN` env var.
5252
4. Create a GitHub Personal Access token for the relevant user (to create/update/delete the GH Discussions). Use the token as `GH_BOT_TOKEN` env var.
53-
5. Run `npm install`
54-
6. Run `npm start` for development.
53+
5. Create `.dev.vars` file and add `NOTION_TOKEN` and `GH_BOT_TOKEN` to it (and other env vars if needed, see below)
54+
6. Run `pnpm generate` to generate TypeScript types for the GraphQL queries.
55+
7. Run `pnpm install`
56+
8. Run `pnpm start` for development.
5557

5658
> We use Wrangler for the Worker development.
5759
60+
## Config
61+
62+
The following configurations can be set in the env of your project, in order to customize how the bot will run:
63+
64+
- `NOTION_TOKEN` - required, a Notion intergraion API key
65+
- `GH_BOT_TOKEN` - requried (also during development)
66+
- `DRY_RUN` - set to `1` if you wish to just test the create/update/delete plan of this bot, without affecting any data on GitHub.
67+
- `ENABLE_FETCH` - Set to `1` to enable. This will enable the `fetch` event for the worker, this is helpful for development if you want to trigger the bot manually, or if you wish your bot to have a manual trigger.
68+
- `CUSTOM_HEADER_LINK` - customize the link added to the header of every GitHub issue/discussion. To use an external like, you can add markdown, for example: `[The Guild's](https://the-guild.dev)`.
69+
70+
For local development, please add your config to a file called `.dev.vars`
71+
5872
## Deployment (as CloudFlare Worker)
5973

6074
- Every change to `main` branch will run CI and deploy to prod.
6175
- Make sure to configure your `NOTION_TOKEN` and `GH_BOT_TOKEN` (PAT) as part of the env vars.
62-
- You can also deploy from local env by running: `npm run deploy`
76+
- You can also deploy from local env by running: `pnpm run deploy`
6377

6478
> If you wish to have a clone of your own, make sure to rename worker name in the `wrangler.toml` file

codegen.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { CodegenConfig } from "@graphql-codegen/cli";
2+
import { config as loadDotenv } from "dotenv";
3+
4+
loadDotenv({
5+
path: ".dev.vars",
6+
});
7+
8+
const config: CodegenConfig = {
9+
schema: [
10+
{
11+
"https://api.github.com/graphql": {
12+
headers: {
13+
Authorization: `Bearer ${process.env.GH_BOT_TOKEN}`,
14+
},
15+
},
16+
},
17+
],
18+
documents: "src/**/*.ts",
19+
generates: {
20+
"src/types.ts": {
21+
config: {
22+
scalars: {
23+
URI: "string",
24+
},
25+
},
26+
plugins: ["typescript", "typescript-operations"],
27+
},
28+
},
29+
};
30+
31+
export default config;

codegen.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)