-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
19 lines (18 loc) · 834 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const core = require('@actions/core')
const github = require('@actions/github')
const { execSync } = require('child_process')
try {
const baseRef = core.getInput('base');
const headRef = core.getInput('head');
console.log('Fetching all refs');
execSync('git fetch --all');
console.log(`Generating changelog for ${baseRef}..${headRef}`);
const logArgs = core.getInput('log-args');
const gitCommand = `git log --no-merges --no-decorate --topo-order --reverse --format='* %s' ${logArgs} ${baseRef}..${headRef}`;
console.log(`Using git log command: ${gitCommand}`);
const changelog = execSync(gitCommand).toString().replace(/'/g, "\\'").replace(/"/g, "\\\"").replace(/\n/g, '\\n');
console.log(`The changelog: ${changelog}`);
core.setOutput('changelog', changelog);
} catch (err) {
core.setFailed(err.message);
}