File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 3232 run : |
3333 git config --global user.email "actions@github.com"
3434 git config --global user.name "GitHub Actions"
35- git add README.md
35+ git add .
3636 git diff --quiet && git diff --staged --quiet || (git commit -m "Update README with table of contents" && git push)
3737 working-directory : ${{ github.workspace }}
Original file line number Diff line number Diff line change 11import fetch from "node-fetch" ;
22import fs from "fs" ;
3+ import path from "path" ;
4+ import { fileURLToPath } from "url" ;
5+
6+ const __filename = fileURLToPath ( import . meta. url ) ;
7+ const __dirname = path . dirname ( __filename ) ;
38
49const toc = async ( ) => {
510 // Fetch from the GitHubAPI
@@ -45,8 +50,11 @@ const toc = async () => {
4550 }
4651 solutionsTable += "<!-- SOLUTIONS TABLE END -->" ;
4752
53+ // Use path.join to create the correct path to README.md
54+ const readmePath = path . join ( __dirname , ".." , "README.md" ) ;
55+
4856 // Read the existing README content
49- let readmeContent = fs . readFileSync ( "README.md" , "utf8" ) ;
57+ let readmeContent = fs . readFileSync ( readmePath , "utf8" ) ;
5058
5159 // Checking whether the solutions table already exists
5260 if ( readmeContent . includes ( "<!-- SOLUTIONS TABLE BEGIN -->" ) ) {
@@ -69,7 +77,7 @@ const toc = async () => {
6977 }
7078
7179 // Write the updated content back to README.md
72- fs . writeFileSync ( "README.md" , readmeContent ) ;
80+ fs . writeFileSync ( readmePath , readmeContent ) ;
7381 console . log ( "README.md has been updated with the solutions table!" ) ;
7482} ;
7583
You can’t perform that action at this time.
0 commit comments