mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2024-12-06 02:09:04 +00:00
Simplify index.js
This commit is contained in:
parent
844e852dde
commit
eda98fb9e5
@ -37,7 +37,7 @@ inputs:
|
|||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'index.js'
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: 'git-commit'
|
icon: 'git-commit'
|
||||||
|
35
index.js
35
index.js
@ -1,13 +1,26 @@
|
|||||||
const core = require('@actions/core');
|
const spawn = require('child_process').spawn;
|
||||||
const exec = require('@actions/exec');
|
const path = require("path");
|
||||||
|
|
||||||
async function run() {
|
const exec = (cmd, args=[]) => new Promise((resolve, reject) => {
|
||||||
try {
|
console.log(`Started: ${cmd} ${args.join(" ")}`)
|
||||||
await exec.exec('sh', ['entrypoint.sh']);
|
const app = spawn(cmd, args, { stdio: 'inherit' });
|
||||||
}
|
app.on('close', code => {
|
||||||
catch (error) {
|
if(code !== 0){
|
||||||
core.setFailed(error.message);
|
err = new Error(`Invalid status code: ${code}`);
|
||||||
}
|
err.code = code;
|
||||||
}
|
return reject(err);
|
||||||
|
};
|
||||||
|
return resolve(code);
|
||||||
|
});
|
||||||
|
app.on('error', reject);
|
||||||
|
});
|
||||||
|
|
||||||
run()
|
const main = async () => {
|
||||||
|
await exec('sh', [path.join(__dirname, './entrypoint.sh')]);
|
||||||
|
};
|
||||||
|
|
||||||
|
main().catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
console.error(err.stack);
|
||||||
|
process.exit(err.code || -1);
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user