-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (36 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const core = require('@actions/core');
const github = require('@actions/github');
const exec = require('@actions/exec');
const folder = core.getInput('folder');
async function run() {
try {
const commits = github.context.payload.commits;
commits.forEach(async commit => {
const id = commit.id;
console.log(commit);
// Check the content using git diff-tree
let output = '';
let error = '';
const options = {};
options.listeners = {
stdout: (data) => {
output += data.toString();
},
stderr: (data) => {
error += data.toString();
}
};
await exec.exec('git', ['diff-tree', '--no-commit-id', '--name-only', '-r', id, '--', folder], options);
//let changes = execSync(`git diff-tree --no-commit-id --name-only -z -r ${id} -- ${folder}`);
if (!error)
console.log(`changes for ${id} - ${output}`);
else
console.error(error);
});
core.setOutput('hasChanges', 0);
}
catch (error) {
core.setFailed(error.message);
}
}
run();