Skip to content

Commit d256439

Browse files
committed
refactor: improve runner log
1 parent 0b7fd8c commit d256439

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/main.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,37 @@ import { parseInputs } from './inputs'
1414
import { createOptions } from './options'
1515
import { parseGitRefs } from './refs'
1616

17+
const LOG_PREFIX = '[Code PushUp GitHub action]'
18+
1719
export async function run(
1820
artifact = new DefaultArtifactClient(),
1921
getOctokit = github.getOctokit,
2022
git = simpleGit()
2123
): Promise<void> {
2224
try {
2325
const inputs = parseInputs()
26+
const options = createOptions(inputs)
27+
28+
const [nodeMayorString] = (
29+
process.version.startsWith('v')
30+
? process.version.slice(1)
31+
: process.version
32+
).split('.')
33+
const majorVersion = parseInt(nodeMayorString, 10)
34+
const isUnsupportedVersion = majorVersion < 20
35+
36+
if (isUnsupportedVersion || options.debug) {
37+
core.warning(
38+
`${LOG_PREFIX} Internal runner is using unsupported NodeJS version ${process.version}`
39+
)
40+
} else if (options.debug) {
41+
core.info(
42+
`${LOG_PREFIX} Internal runner is using NodeJS version ${process.version}`
43+
)
44+
}
2445

2546
const refs = parseGitRefs()
2647
const api = new GitHubApiClient(inputs.token, refs, artifact, getOctokit)
27-
const options = createOptions(inputs)
28-
29-
console.log('Running with NodeJS version', process.version)
3048

3149
const result = await runInCI(refs, api, options, git)
3250

@@ -95,5 +113,8 @@ export async function run(
95113
const errorMessage = error instanceof Error ? error.message : `${error}`
96114
core.error(errorMessage)
97115
core.setFailed(errorMessage)
116+
return
98117
}
118+
119+
core.info(`${LOG_PREFIX} Finished running successfully`)
99120
}

0 commit comments

Comments
 (0)