Skip to content

Commit f0c2e31

Browse files
committed
Merge branch 'main' of https://github.com/benWu26/LeetStudy
2 parents c789251 + 2b3d532 commit f0c2e31

40 files changed

+1338
-215
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and Deploy Frontend to Google Cloud
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'website/**'
8+
- '.github/workflows/frontend-docker.yml'
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
id-token: write # Needed for GCP authentication
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
# Authenticate to Google Cloud with service account key
26+
- id: 'auth'
27+
name: 'Authenticate to Google Cloud'
28+
uses: 'google-github-actions/auth@v2'
29+
with:
30+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
31+
32+
# Configure docker to use gcloud as a credential helper
33+
- name: Set up Cloud SDK
34+
uses: 'google-github-actions/setup-gcloud@v2'
35+
36+
- name: Configure Docker for GCP Artifact Registry
37+
run: |
38+
gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev
39+
40+
# Build and push the Docker image to Google Artifact Registry
41+
- name: Build and push
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: ./website
45+
push: true
46+
tags: |
47+
${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/leetstudy/frontend:latest
48+
${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/leetstudy/frontend:${{ github.sha }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
52+
# Deploy to Cloud Run
53+
- name: Deploy to Cloud Run
54+
id: deploy
55+
uses: google-github-actions/deploy-cloudrun@v2
56+
with:
57+
service: leetstudy-frontend
58+
image: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/leetstudy/frontend:${{ github.sha }}
59+
region: ${{ secrets.GCP_REGION }}
60+
flags: |
61+
--allow-unauthenticated
62+
--port=8080
63+
--cpu=1
64+
--memory=512Mi
65+
--timeout=300s
66+
--min-instances=0
67+
--max-instances=10
68+
--concurrency=80
69+
70+
# Debug service information
71+
- name: Debug Service Info
72+
run: |
73+
echo "Deployed URL: ${{ steps.deploy.outputs.url }}"
74+
gcloud run services describe leetstudy-frontend --region=${{ secrets.GCP_REGION }} --format=json
75+
echo "Checking if service is reachable..."
76+
curl -v ${{ steps.deploy.outputs.url }}
77+
if: always()

.github/workflows/website.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Website CI
22

33
on:
4-
push:
5-
branches: [ "main" ]
64
pull_request:
75
branches: [ "main" ]
86

AI-testing/output.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"cells": [
33
{
44
"cell_type": "markdown",

extension-shad-ts/public/manifest.json

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,50 @@
33
"name": "LeetStudy Extension TS",
44
"version": "1.0",
55
"description": "Leetstudy",
6-
"background": {
7-
"service_worker": "service-worker.js"
8-
},
9-
"permissions": ["sidePanel", "activeTab", "tabs", "storage", "scripting", "cookies", "storage"],
6+
7+
"background": {
8+
"service_worker": "service-worker.js",
9+
"type": "module"
10+
},
11+
12+
"permissions": ["sidePanel", "activeTab", "tabs", "storage", "scripting", "cookies", "storage", "commands"],
1013
"host_permissions": ["*://*.leetcode.com/*",
1114
"http://localhost:8080/*",
1215
"http://localhost:5173/*"],
1316
"action": {
1417
"default_title": "Open LeetStudy Side Panel"
1518
},
1619
"commands": {
20+
"open_shortcuts": {
21+
"suggested_key": {
22+
"default": "Ctrl+Shift+P",
23+
"mac": "Command+Shift+P"
24+
},
25+
"description": "Open Shortcuts"
26+
},
27+
"open_whiteboard": {
28+
"suggested_key": {
29+
"default": "Ctrl+Shift+Y",
30+
"mac": "Command+Shift+Y"
31+
},
32+
"description": "Open Whiteboard"
33+
},
34+
"font_increase": {
35+
"suggested_key": {
36+
"default": "Ctrl+Shift+K",
37+
"mac": "Command+Shift+K"
38+
},
39+
"description": "Font increase"
40+
},
41+
"font_decrease": {
42+
"suggested_key": {
43+
"default": "Ctrl+Shift+L",
44+
"mac": "Command+Shift+L"
45+
},
46+
"description": "Font decrease"
47+
}
1748

18-
},
49+
},
1950

2051
"icons": {
2152
"16": "images/icon-16.png",

extension-shad-ts/public/service-worker.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const LEET_ORIGIN = 'https://leetcode.com/';
2-
32
/*
43
chrome.tabs.onUpdated.addListener(async (tabId, info, tab) => {
54
if (!tab.url) return;
@@ -59,4 +58,28 @@ chrome.runtime.onMessage.addListener((msg, sender) => {
5958
//opens the side panel when user presses the icon
6059
chrome.sidePanel
6160
.setPanelBehavior({ openPanelOnActionClick: true })
62-
.catch((error) => console.error(error));
61+
.catch((error) => console.error(error));
62+
63+
chrome.commands.onCommand.addListener(async (command) => {
64+
if (command === "open_whiteboard") {
65+
console.log("Opening whiteboard side panel");
66+
// 1) Open the side panel
67+
68+
69+
// 2) Then send a runtime message that the side-panel can pick up
70+
chrome.runtime.sendMessage({ action: "whiteboard" });
71+
} else if (command === "open_customize") {
72+
console.log("Opening whiteboard side panel");
73+
// 1) Open the side panel
74+
75+
76+
// 2) Then send a runtime message that the side-panel can pick up
77+
chrome.runtime.sendMessage({ action: "customize" });
78+
}else if(command === "font_increase"){
79+
chrome.runtime.sendMessage({ action: "font_increase" });
80+
}else if(command === "font_decrease"){
81+
chrome.runtime.sendMessage({ action: "font_decrease" });
82+
}else if(command === "open_shortcuts"){
83+
chrome.runtime.sendMessage({ action: "shortcuts" });
84+
}
85+
});

0 commit comments

Comments
 (0)