semantic-branch-version/index.js

33 lines
705 B
JavaScript
Raw Normal View History

const core = require('@actions/core');
2020-07-04 23:47:33 +08:00
const execlib = require('@actions/exec');
try {
2020-07-05 00:45:30 +08:00
const branchName = getBranchName();
core.setOutput("branchname", branchName);
2020-07-05 14:42:39 +08:00
if (branchName) {
console.log('We got it! : ' + branchName);
}
2020-07-05 00:45:30 +08:00
} catch (error) {
core.setFailed(error.message);
}
async function getBranchName() {
let output = '';
2020-07-04 23:47:33 +08:00
const options = {
listeners: {
2020-07-05 14:42:39 +08:00
stdout: (data) => {
output += data.toString();
console.log(data);
}
2020-07-05 01:03:59 +08:00
}
2020-07-04 23:47:33 +08:00
};
2020-07-05 00:43:20 +08:00
await execlib.exec('git', ['branch'], options);
2020-07-05 00:45:30 +08:00
2020-07-05 14:42:39 +08:00
if (output) {
console.log('Got some sweet output...' + output);
}
2020-07-05 00:45:30 +08:00
return output;
}