File tree 4 files changed +76
-11
lines changed
4 files changed +76
-11
lines changed Original file line number Diff line number Diff line change
1
+ name : Deploy to GitHub Pages
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main # 触发分支
7
+
8
+ jobs :
9
+ deploy :
10
+ runs-on : ubuntu-latest
11
+
12
+ steps :
13
+ - name : Checkout code
14
+ uses : actions/checkout@v3
15
+
16
+ - name : Set up Node.js
17
+ uses : actions/setup-node@v3
18
+ with :
19
+ node-version : 16
20
+
21
+ - name : Install dependencies
22
+ run : npm install
23
+
24
+ - name : Build project
25
+ run : npm run build # 假设构建输出到 dist 文件夹
26
+
27
+ - name : Deploy to GitHub Pages
28
+ uses : peaceiris/actions-gh-pages@v3
29
+ with :
30
+ github_token : ${{ secrets.GITHUB_TOKEN }}
31
+ publish_dir : ./dist # 将 dist 文件夹部署到 gh-pages 分支
Original file line number Diff line number Diff line change 5
5
"repository" :
" [email protected] :JSREI/js-script-hook-goat.git" ,
6
6
"author" :
" CC11001100 <[email protected] >" ,
7
7
"license" : " MIT" ,
8
+ "scripts" : {
9
+ "pages" : " node pages.js" ,
10
+ "start" : " node index.js"
11
+ },
8
12
"dependencies" : {
9
13
"crypto-js" : " ^4.2.0" ,
10
14
"express" : " ^4.21.2" ,
11
15
"body-parser" : " ^1.20.3"
12
16
}
13
- }
17
+ }
Original file line number Diff line number Diff line change
1
+ const fs = require ( 'fs' ) ;
2
+ const path = require ( 'path' ) ;
3
+
4
+ // 定义源文件夹和目标文件夹
5
+ const sourceDir = path . join ( __dirname , 'public' ) ;
6
+ const targetDir = path . join ( __dirname , 'docs' ) ;
7
+
8
+ // 确保目标文件夹存在
9
+ if ( ! fs . existsSync ( targetDir ) ) {
10
+ fs . mkdirSync ( targetDir , { recursive : true } ) ;
11
+ }
12
+
13
+ // 递归复制文件夹内容
14
+ function copyFolderRecursive ( source , target ) {
15
+ // 读取源文件夹内容
16
+ const files = fs . readdirSync ( source ) ;
17
+
18
+ for ( const file of files ) {
19
+ const sourcePath = path . join ( source , file ) ;
20
+ const targetPath = path . join ( target , file ) ;
21
+
22
+ // 判断是文件还是文件夹
23
+ const stat = fs . statSync ( sourcePath ) ;
24
+ if ( stat . isDirectory ( ) ) {
25
+ // 如果是文件夹,递归复制
26
+ if ( ! fs . existsSync ( targetPath ) ) {
27
+ fs . mkdirSync ( targetPath , { recursive : true } ) ;
28
+ }
29
+ copyFolderRecursive ( sourcePath , targetPath ) ;
30
+ } else {
31
+ // 如果是文件,直接复制
32
+ fs . copyFileSync ( sourcePath , targetPath ) ;
33
+ console . log ( `Copied: ${ sourcePath } -> ${ targetPath } ` ) ;
34
+ }
35
+ }
36
+ }
37
+
38
+ // 执行复制
39
+ copyFolderRecursive ( sourceDir , targetDir ) ;
40
+ console . log ( 'All files copied from public to docs!' ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments