File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 1- import fs from "fs" ;
2- import fetch from "node-fetch" ;
1+ const fs = require ( "fs" ) ;
2+ const fetch = require ( "node-fetch" ) ;
33
4- const username = "hogantech" ;
4+ const username = "hogantech" ;
55const url = `https://leetcard.jacoblin.cool/${ username } ?ext=heatmap` ;
6-
76const outputPath = "./assets/leetcode.svg" ;
87
98async function updateLeetCodeCard ( ) {
@@ -12,9 +11,10 @@ async function updateLeetCodeCard() {
1211 if ( ! response . ok ) throw new Error ( `HTTP ${ response . status } ` ) ;
1312 const svg = await response . text ( ) ;
1413 fs . writeFileSync ( outputPath , svg ) ;
15- console . log ( "LeetCode stats card updated successfully!" ) ;
14+ console . log ( "✅ LeetCode stats card updated successfully!" ) ;
1615 } catch ( err ) {
17- console . error ( "Failed to update LeetCode stats:" , err ) ;
16+ console . error ( "❌ Failed to update LeetCode stats:" , err ) ;
17+ process . exit ( 1 ) ;
1818 }
1919}
2020
Original file line number Diff line number Diff line change 77 - cron : " 0 */2 * * *"
88
99jobs :
10- # ---------- LeetCode job ----------
1110 update-leetcode :
1211 name : Update local LeetCode stats card
1312 runs-on : ubuntu-latest
13+
1414 steps :
1515 - name : Checkout repository
1616 uses : actions/checkout@v4
17+ with :
18+ persist-credentials : true
1719
1820 - name : Setup Node.js
1921 uses : actions/setup-node@v4
2022 with :
2123 node-version : 20
2224
2325 - name : Install dependencies
24- run : npm install node-fetch@3
26+ run : npm install node-fetch@2
2527
2628 - name : Generate latest LeetCode SVG
2729 run : |
2830 mkdir -p assets
2931 node .github/scripts/update_leetcode.js
3032
3133 - name : Commit and push updated LeetCode card
34+ env :
35+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3236 run : |
3337 git config user.name "github-actions[bot]"
3438 git config user.email "github-actions[bot]@users.noreply.github.com"
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " leetcode-solution" ,
3+ "version" : " 1.0.0" ,
4+ "type" : " module" ,
5+ "dependencies" : {
6+ "node-fetch" : " ^3.3.2"
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments