mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-18 09:52:35 +00:00
fix: use async/await in the runner
This commit is contained in:
parent
cd7e423dd8
commit
e300660370
2 changed files with 14 additions and 13 deletions
18
src/index.ts
18
src/index.ts
|
|
@ -2,14 +2,16 @@ import * as core from '@actions/core';
|
||||||
import Input from './input';
|
import Input from './input';
|
||||||
import Renovate from './renovate';
|
import Renovate from './renovate';
|
||||||
|
|
||||||
function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
const input = new Input();
|
try {
|
||||||
const renovate = new Renovate(input.configurationFile, input.token);
|
const input = new Input();
|
||||||
|
const renovate = new Renovate(input.configurationFile, input.token);
|
||||||
|
|
||||||
return renovate.runDockerContainer();
|
await renovate.runDockerContainer();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
core.setFailed(error.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run().catch((error) => {
|
run();
|
||||||
console.error(error);
|
|
||||||
core.setFailed(error.message);
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,17 @@ class Renovate {
|
||||||
this.docker = new Docker();
|
this.docker = new Docker();
|
||||||
}
|
}
|
||||||
|
|
||||||
runDockerContainer(): Promise<void> {
|
async runDockerContainer(): Promise<void> {
|
||||||
const commandArguments = [
|
const commandArguments = [
|
||||||
'run',
|
|
||||||
'--rm',
|
'--rm',
|
||||||
`--env ${this.configFileEnv}=${this.configFileMountPath()}`,
|
`--env ${this.configFileEnv}=${this.configFileMountPath()}`,
|
||||||
`--env ${this.tokenEnv}=${this.token}`,
|
`--env ${this.tokenEnv}=${this.token}`,
|
||||||
`--volume ${this.configFile}:${this.configFileMountPath()}`,
|
`--volume ${this.configFile}:${this.configFileMountPath()}`,
|
||||||
this.docker.image(),
|
this.docker.image(),
|
||||||
];
|
];
|
||||||
const command = `docker`;
|
const command = `docker run ${commandArguments.join(' ')}`;
|
||||||
|
|
||||||
const code = exec(command, commandArguments);
|
const code = await exec(command);
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
new Error(`'docker run' failed with exit code ${code}.`);
|
new Error(`'docker run' failed with exit code ${code}.`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue