Fail builds on non-zero exit codes.

This commit is contained in:
Fabio Niephaus
2022-03-11 10:35:03 +01:00
committed by Fabio Niephaus
parent 77fd73038b
commit b3777a3c57
4 changed files with 19 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import * as c from './constants'
import * as core from '@actions/core'
import * as httpClient from '@actions/http-client'
import * as tc from '@actions/tool-cache'
import {ExecOptions, exec as e} from '@actions/exec'
import {readFileSync, readdirSync} from 'fs'
import {Octokit} from '@octokit/core'
import {createHash} from 'crypto'
@@ -16,6 +17,21 @@ const GitHub = Octokit.defaults({
}
})
export async function exec(
commandLine: string,
args?: string[],
options?: ExecOptions | undefined
): Promise<void> {
const exitCode = await e(commandLine, args, options)
if (exitCode !== 0) {
throw new Error(
`'${[commandLine]
.concat(args || [])
.join(' ')}' exited with a non-zero code: ${exitCode}`
)
}
}
export async function getLatestRelease(
repo: string
): Promise<c.LatestReleaseResponse['data']> {