cshenfu
2024-06-27 58aa6e282bb343503be3cb198948328ea3ed7b79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fs = require('fs');
module.exports = function(){
    console.log('开始执行脚本change_after');
    let changelog = fs.readFileSync(process.cwd() + '/changelog.md', 'utf-8').split("##")[1].split("\n").slice(1).join(' ');
    console.log(changelog);
    // 这里是修改完相关敏感配置后执行的脚本,你可以在这里自定义逻辑,
    // 比如执行git提交命令
    var shell = require("shelljs");
    var exec = shell.exec;
    
    if (exec('git add .').code !== 0) {
      shell.echo('Error: Git add failed');
      shell.exit(1);
    }
    if (exec(`git commit -a -m "${changelog}"`).code !== 0) {
      shell.echo('Error: Git commit failed');
      shell.exit(1);
    }
    if (exec('git push').code !== 0) {
      shell.echo('Error: Git commit failed');
      shell.exit(1);
    }
    shell.exec(`echo git success ${changelog}`);
}