Skip to content

Commit e54e96f

Browse files
author
msingh
committed
update readme and minor fixes
1 parent b6a30ef commit e54e96f

File tree

3 files changed

+126
-4
lines changed

3 files changed

+126
-4
lines changed

README.md

Lines changed: 123 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,123 @@
1-
# leetcode-notion-automation
2-
Automatic Addition of LeetCode submission in Notion Table
1+
# LeetCode Notion Automation
2+
3+
## Overview
4+
The **LeetCode Notion Automation** project automates the process of adding LeetCode submissions to a Notion database. It fetches the accepted submissions of a specified user from LeetCode using the public GraphQL API, filters the submissions for the current day, and adds them to a Notion database.
5+
6+
## Features
7+
- Automatically fetches accepted submissions from LeetCode.
8+
- Filters submissions for the current day.
9+
- Adds submissions to a Notion database.
10+
- Scheduled to run daily at 23:30 UTC using GitHub Actions.
11+
12+
## Prerequisites
13+
- **Node.js**: Ensure you have Node.js (version 16 or above) installed on your machine.
14+
- **Git**: Ensure you have Git installed for cloning the repository.
15+
- **Notion Account**: Create a Notion account if you don’t have one.
16+
- **LeetCode Account**: Create a LeetCode account if you don’t have one.
17+
18+
## Getting Started
19+
20+
### 1. Clone the Repository
21+
```bash
22+
git clone https://github.com/msn2106/leetcode-notion-automation.git
23+
cd leetcode-notion-automation
24+
```
25+
26+
### 2. Install Dependencies
27+
Run the following command to install the required dependencies:
28+
```bash
29+
npm install
30+
```
31+
32+
### 3. Configure Your Credentials
33+
Create a config.json file in the root directory of the project with the following structure:
34+
```json
35+
{
36+
"leetcodeUsername": "your_leetcode_username",
37+
"notionApiKey": "your_notion_integration_token",
38+
"NOTION_DATABASE_NAME": "LeetCode Problems",
39+
"notionParentPageId": "your_notion_parent_page_id"
40+
}
41+
```
42+
- leetcodeUsername: Your LeetCode username.
43+
- notionApiKey: Your Notion integration token. You can create an integration in Notion and get the token from there.
44+
- NOTION_DATABASE_NAME: The name of the database where submissions will be added.
45+
- notionParentPageId: (Optional) The ID of the parent page where the database will be created.
46+
47+
### 4. Set Up Notion Integration
48+
Go to your Notion workspace.
49+
Create a new integration from Notion Integrations.
50+
Copy the integration token and paste it into the notionApiKey field in config.json.
51+
Share the database with the integration by going to the database settings and inviting the integration.
52+
53+
### 5. Testing the Script Locally
54+
You can run the script locally to test if everything is set up correctly:
55+
```bash
56+
node index.js
57+
```
58+
59+
This will fetch the recent accepted submissions and add them to your Notion database.
60+
61+
### 6. Set Up GitHub Actions for Daily Automation
62+
To automate the process, you can set up GitHub Actions to run the script daily.
63+
64+
Go to your GitHub repository.
65+
Navigate to Settings > Secrets and variables > Actions.
66+
Click on New repository secret and add the following secrets:
67+
LEETCODE_USERNAME: Your LeetCode username.
68+
NOTION_API_KEY: Your Notion integration token.
69+
NOTION_DATABASE_NAME: The name of the database (optional, can be hardcoded).
70+
NOTION_PARENT_PAGE_ID: The ID of the parent page (optional, can be hardcoded).
71+
72+
### 7. Configure the GitHub Actions Workflow
73+
The workflow file is already set up to run daily at 23:30 UTC. You can find it in the .github/workflows/daily-update.yml file. You may customize the schedule according to your preferences.
74+
75+
### 8. Commit and Push Your Changes
76+
After setting everything up, commit your changes and push them to your GitHub repository:
77+
```bash
78+
git add .
79+
git commit -m "Setup LeetCode Notion Automation"
80+
git push origin main
81+
```
82+
83+
### 9. Usage
84+
Once everything is set up and the GitHub Actions workflow is configured, the script will run daily at the specified time, fetching the current day's accepted submissions from LeetCode and adding them to your Notion database.
85+
86+
Viewing Your Notion Database
87+
You can view your submissions in the specified Notion database. The database will contain the following fields:
88+
89+
- Problem Name: The name of the problem.
90+
- Problem Number: The ID of the problem.
91+
- Link: A link to the problem on LeetCode.
92+
- Submission Date: The date of the submission.
93+
- Tags: Tags associated with the problem.
94+
- Difficulty: The difficulty level of the problem.
95+
- Status: The status of the submission (Accepted).
96+
97+
### 10. Contributing
98+
#### Contributing Contributions are welcome! If you would like to contribute to this project, please follow these steps:
99+
- 1. Fork the Repository: Click on the "Fork" button at the top right of the repository page to create your own copy of the project.
100+
- 2. Create a New Branch: Create a new branch for your feature or bug fix:
101+
```bash
102+
git checkout -b feature/your-feature-name
103+
```
104+
- 3. Make Your Changes: Implement your changes and ensure that the code is well-tested.
105+
- 4. Commit Your Changes: Commit your changes with a descriptive message:
106+
```bash
107+
git commit -m "Add feature: your feature description"
108+
```
109+
- 5. Push to Your Fork: Push your changes to your forked repository:
110+
```bash
111+
git push origin feature/your-feature-name
112+
```
113+
- 6. Create a Pull Request: Go to the original repository and create a pull request from your forked repository.
114+
115+
### 11. License
116+
This project is licensed under the MIT License. See the LICENSE file for details.
117+
118+
### 12. Acknowledgments
119+
Thanks to the LeetCode team for providing the public GraphQL API.
120+
Thanks to the Notion team for their API, which allows seamless integration with external applications.
121+
122+
### 13. Contact
123+
For any questions or feedback, feel free to reach out via GitHub Issues or contact me directly at [msn2106@gmail.com].

config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"leetcodeUsername": "msn2106",
33
"notionApiKey": "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",
4-
"NOTION_DATABASE_NAME": "LeetCode Problems"
4+
"NOTION_DATABASE_NAME": "LeetCode Problems",
5+
"notionParentPageId": ""
56
}

notion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function getOrCreateNotionDatabase() {
1515
// Create new database
1616
const response = await notion.databases.create({
1717
parent: { type: "page_id", page_id: config.notionParentPageId },
18-
title: [{ type: "text", text: { content: NOTION_DATABASE_NAME } }],
18+
title: [{ type: "text", text: { content: config.NOTION_DATABASE_NAME } }],
1919
properties: {
2020
Name: { title: {} },
2121
Link: { url: {} },

0 commit comments

Comments
 (0)