feat: add commit_long_sha output (#349)
This commit is contained in:
@@ -24,6 +24,7 @@ export type input = keyof InputTypes
|
||||
|
||||
interface OutputTypes {
|
||||
committed: 'true' | 'false'
|
||||
commit_long_sha: string | undefined
|
||||
commit_sha: string | undefined
|
||||
pushed: 'true' | 'false'
|
||||
tagged: 'true' | 'false'
|
||||
@@ -32,6 +33,7 @@ export type output = keyof OutputTypes
|
||||
|
||||
export const outputs: OutputTypes = {
|
||||
committed: 'false',
|
||||
commit_long_sha: undefined,
|
||||
commit_sha: undefined,
|
||||
pushed: 'false',
|
||||
tagged: 'false'
|
||||
|
||||
27
src/main.ts
27
src/main.ts
@@ -1,6 +1,6 @@
|
||||
import * as core from '@actions/core'
|
||||
import path from 'path'
|
||||
import simpleGit, { CommitSummary, Response } from 'simple-git'
|
||||
import simpleGit, { Response } from 'simple-git'
|
||||
import { checkInputs, getInput, logOutputs, setOutput } from './io'
|
||||
import { log, matchGitArgs, parseInputArray } from './util'
|
||||
|
||||
@@ -70,17 +70,20 @@ core.info(`Running in ${baseDir}`)
|
||||
} else core.info('> Not pulling from repo.')
|
||||
|
||||
core.info('> Creating commit...')
|
||||
await git.commit(
|
||||
getInput('message'),
|
||||
matchGitArgs(getInput('commit') || ''),
|
||||
(err, data?: CommitSummary) => {
|
||||
if (data) {
|
||||
setOutput('committed', 'true')
|
||||
setOutput('commit_sha', data.commit)
|
||||
}
|
||||
return log(err, data)
|
||||
}
|
||||
)
|
||||
const commitData = await git
|
||||
.commit(getInput('message'), matchGitArgs(getInput('commit') || ''))
|
||||
.catch((err) => {
|
||||
log(err)
|
||||
})
|
||||
if (commitData) {
|
||||
log(undefined, commitData)
|
||||
setOutput('committed', 'true')
|
||||
setOutput('commit_sha', commitData.commit)
|
||||
await git
|
||||
.revparse(commitData.commit)
|
||||
.then((long_sha) => setOutput('commit_long_sha', long_sha))
|
||||
.catch((err) => core.warning(`Couldn't parse long SHA:\n${err}`))
|
||||
}
|
||||
|
||||
if (getInput('tag')) {
|
||||
core.info('> Tagging commit...')
|
||||
|
||||
Reference in New Issue
Block a user