Skip to content

Commit

Permalink
refactor: updated imports and usage; applied default run
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Sep 18, 2021
1 parent 564cab1 commit e18d952
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/run-runbook.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {ExecOptions, exec} from '@actions/exec'
import {info, setFailed} from '@actions/core'
import {InputParameters} from './input-parameters'
import * as core from '@actions/core'
import * as exec from '@actions/exec'

function getArgs(parameters: InputParameters): string[] {
core.info('🔣 Parsing inputs...')
info('🔣 Parsing inputs...')

const args = ['run-runbook']

Expand Down Expand Up @@ -71,42 +71,43 @@ function getArgs(parameters: InputParameters): string[] {

export async function runRunbook(parameters: InputParameters): Promise<void> {
const args = getArgs(parameters)

const options: exec.ExecOptions = {
ignoreReturnCode: true,
const options: ExecOptions = {
listeners: {
errline: (line: string) => {
core.error(line)
},
stdline: (line: string) => {
if (line.length <= 0) return
if (line.length === 0) return

if (line.includes('Octopus Deploy Command Line Tool')) {
const version = line.split('version ')[1]
core.info(`🐙 Using Octopus Deploy CLI ${version}...`)
info(`🐙 Using Octopus Deploy CLI ${version}...`)
return
}

if (line.includes('Handshaking with Octopus Server')) {
core.info(`🤝 Handshaking with Octopus Deploy`)
info(`🤝 Handshaking with Octopus Deploy`)
return
}

if (line.includes('Authenticated as:')) {
core.info(`✅ Authenticated`)
info(`✅ Authenticated`)
return
}

if (line === 'Done!') {
core.info(`🎉 Runbook complete!`)
info(`🎉 Runbook complete!`)
return
}

core.info(line)
info(line)
}
},
silent: true
}

await exec.exec('octo', args, options)
try {
await exec('octo', args, options)
} catch (e: unknown) {
if (e instanceof Error) {
setFailed(e)
}
}
}

0 comments on commit e18d952

Please sign in to comment.