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

@ -1,6 +1,6 @@
import * as core from '@actions/core'
import {GRAALVM_PLATFORM} from './constants'
import {exec} from '@actions/exec'
import {exec} from './utils'
const APT_GET_INSTALL_BASE = 'sudo apt-get -y --no-upgrade install'
const COMPONENT_TO_DEPS = new Map<string, Map<string, string>>([

View File

@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import {IS_LINUX} from './constants'
import {exec} from '@actions/exec'
import {exec} from './utils'
import {join} from 'path'
const MUSL_NAME = 'x86_64-linux-musl-native'

View File

@ -1,5 +1,5 @@
import {GRAALVM_PLATFORM} from './constants'
import {exec} from '@actions/exec'
import {exec} from './utils'
import {join} from 'path'
const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress']

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']> {