-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7320679
commit d08fdfe
Showing
4 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # 触发分支 | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build project | ||
run: npm run build # 假设构建输出到 dist 文件夹 | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./dist # 将 dist 文件夹部署到 gh-pages 分支 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,13 @@ | |
"repository": "[email protected]:JSREI/js-script-hook-goat.git", | ||
"author": "CC11001100 <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"pages": "node pages.js", | ||
"start": "node index.js" | ||
}, | ||
"dependencies": { | ||
"crypto-js": "^4.2.0", | ||
"express": "^4.21.2", | ||
"body-parser": "^1.20.3" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// 定义源文件夹和目标文件夹 | ||
const sourceDir = path.join(__dirname, 'public'); | ||
const targetDir = path.join(__dirname, 'docs'); | ||
|
||
// 确保目标文件夹存在 | ||
if (!fs.existsSync(targetDir)) { | ||
fs.mkdirSync(targetDir, { recursive: true }); | ||
} | ||
|
||
// 递归复制文件夹内容 | ||
function copyFolderRecursive(source, target) { | ||
// 读取源文件夹内容 | ||
const files = fs.readdirSync(source); | ||
|
||
for (const file of files) { | ||
const sourcePath = path.join(source, file); | ||
const targetPath = path.join(target, file); | ||
|
||
// 判断是文件还是文件夹 | ||
const stat = fs.statSync(sourcePath); | ||
if (stat.isDirectory()) { | ||
// 如果是文件夹,递归复制 | ||
if (!fs.existsSync(targetPath)) { | ||
fs.mkdirSync(targetPath, { recursive: true }); | ||
} | ||
copyFolderRecursive(sourcePath, targetPath); | ||
} else { | ||
// 如果是文件,直接复制 | ||
fs.copyFileSync(sourcePath, targetPath); | ||
console.log(`Copied: ${sourcePath} -> ${targetPath}`); | ||
} | ||
} | ||
} | ||
|
||
// 执行复制 | ||
copyFolderRecursive(sourceDir, targetDir); | ||
console.log('All files copied from public to docs!'); |
This file was deleted.
Oops, something went wrong.