feat: add outputs

re #96
This commit is contained in:
Federico Grandi
2020-12-05 16:34:50 +01:00
parent 28fa18d5af
commit fe1fb219a6
4 changed files with 9890 additions and 41 deletions

42
src/util.ts Normal file
View File

@@ -0,0 +1,42 @@
import core from '@actions/core'
export type Input =
| 'add'
| 'author_name'
| 'author_email'
| 'branch'
| 'cwd'
| 'message'
| 'pull_strategy'
| 'push'
| 'remove'
| 'signoff'
| 'tag'
export const outputs = {
committed: 'false',
pushed: 'false',
tagged: 'false'
}
export type Output = keyof typeof outputs
export function getInput(name: Input) {
return core.getInput(name)
}
export function log(err: any | Error, data?: any) {
if (data) console.log(data)
if (err) core.error(err)
}
export function parseBool(value: any) {
try {
const parsed = JSON.parse(value)
if (typeof parsed == 'boolean') return parsed
} catch {}
}
export function setOutput(name: Output, value: 'true' | 'false') {
core.setOutput(name, value)
}
for (const key in outputs) setOutput(key as Output, outputs[key])