Skip to content

Commit 4709207

Browse files
优化目录结构 (#24)
--------- Co-authored-by: GitHub Action <[email protected]>
1 parent 445f809 commit 4709207

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

.github/workflows/sync-authors.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,30 @@ jobs:
2323
run: npm install
2424

2525
- name: 同步作者信息
26-
run: node sync_authors.js
26+
run: node build/sync_authors.js
2727

2828
- name: 检查文件变更
2929
id: verify-changed-files
3030
run: |
3131
# 检查 author_mapping.json 是否有变更
32-
if git diff --quiet author_mapping.json; then
32+
if git diff --quiet assets/author_mapping.json; then
3333
echo "changed=false" >> $GITHUB_OUTPUT
34-
echo "author_mapping.json 没有变更"
34+
echo "assets/author_mapping.json 没有变更"
3535
else
3636
echo "changed=true" >> $GITHUB_OUTPUT
37-
echo "author_mapping.json 有变更"
37+
echo "assets/author_mapping.json 有变更"
3838
fi
3939
4040
- name: 提交变更
4141
if: steps.verify-changed-files.outputs.changed == 'true'
4242
run: |
4343
git config --local user.email "[email protected]"
4444
git config --local user.name "GitHub Action"
45-
git add author_mapping.json
45+
git add assets/author_mapping.json
4646
git commit -m "自动更新作者映射信息 [skip ci]"
4747
git push
4848
4949
- name: 无变更提示
5050
if: steps.verify-changed-files.outputs.changed == 'false'
5151
run: |
52-
echo "author_mapping.json 没有变更,跳过提交"
52+
echo "assets/author_mapping.json 没有变更,跳过提交"
File renamed without changes.

notify.js renamed to build/notify.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ async function notifyAuthors() {
5555
// 读取作者映射
5656
let authorMapping;
5757
try {
58-
authorMapping = JSON.parse(fs.readFileSync('author_mapping.json', 'utf8'));
58+
authorMapping = JSON.parse(fs.readFileSync('assets/author_mapping.json', 'utf8'));
5959
} catch (error) {
60-
console.log('读取 author_mapping.json 失败:', error.message);
60+
console.log('读取 assets/author_mapping.json 失败:', error.message);
6161
return;
6262
}
6363

@@ -75,7 +75,7 @@ async function notifyAuthors() {
7575
}).join(' ');
7676

7777
// 构建通知评论
78-
const notificationComment = `🔔 **脚本评论通知**\n\n${mentions}\n\n📁 **脚本路径:** \n\`${scriptPath}\`\n💬 **评论内容:**\n${comment.body}\n\n🔗 **评论区链接:** [#${discussion.number}](${discussion.html_url})`;
78+
const notificationComment = `🔔 **脚本评论通知**\n\n${mentions}\n\n📁 **脚本路径:** \n\`${scriptPath}\`\n\n💬 **评论内容:**\n${comment.body}\n\n🔗 **评论区链接:** [#${discussion.number}](${discussion.html_url})`;
7979

8080
// 发送通知
8181
try {

sync_authors.js renamed to build/sync_authors.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ async function syncAuthors() {
134134
console.log(`解析完成,共找到 ${authorMapping.length} 个路径`);
135135

136136
// 写入 author_mapping.json
137-
const outputPath = 'author_mapping.json';
137+
// 获取项目根目录路径
138+
const projectRoot = path.resolve(__dirname, '..');
139+
const outputPath = path.join(projectRoot, 'assets', 'author_mapping.json');
138140
fs.writeFileSync(outputPath, JSON.stringify(authorMapping, null, 2), 'utf8');
139141
console.log(`作者映射已更新到 ${outputPath}`);
140142

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"@octokit/core": "^5.0.0"
55
},
66
"scripts": {
7-
"sync": "node sync_authors.js",
8-
"notify": "node notify.js"
7+
"sync": "node build/sync_authors.js",
8+
"notify": "node build/notify.js"
99
}
1010
}

0 commit comments

Comments
 (0)