Skip to content

Commit

Permalink
lib.ts: adjust status logging levels
Browse files Browse the repository at this point in the history
GitHub reports when workflow runs log messages with `notice` or higher
logging levels, e.g.:

> There are 0 failures, 0 warnings, and 1 notices.

Since `notice` was being used regardless of status, these reports were
misleading, because everything was working correctly on successes and 
no-ops.

Therefore, the successes and no-ops now only log with `info`, and the 
failures now only log with `error` (which is perhaps more appropriate
than `notice` for errors).
  • Loading branch information
hemberger committed Feb 13, 2022
1 parent 76a601a commit b19683e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/lib.ts
@@ -1,4 +1,4 @@
import {exportVariable, info, notice, setFailed, setOutput} from '@actions/core'
import {exportVariable, info, error, setFailed, setOutput} from '@actions/core'
import {ActionInterface, NodeActionInterface, Status} from './constants'
import {deploy, init} from './git'
import {configureSSH} from './ssh'
Expand Down Expand Up @@ -68,21 +68,18 @@ export default async function run(

await init(settings)
status = await deploy(settings)
} catch (error) {
} catch (err) {
status = Status.FAILED

setFailed(extractErrorMessage(error))
setFailed(extractErrorMessage(err))
} finally {
const terminationMessage = `${
status === Status.FAILED
? 'Deployment failed! ❌'
: status === Status.SUCCESS
? 'Completed deployment successfully! ✅'
: 'There is nothing to commit. Exiting early… 📭'
}`

info(terminationMessage)
notice(terminationMessage)
if (status === Status.FAILED) {
error('Deployment failed! ❌')
} else if (status === Status.SUCCESS) {
info('Completed deployment successfully! ✅')
} else {
info('There is nothing to commit. Exiting early… 📭')
}

exportVariable('deployment_status', status)
setOutput('deployment-status', status)
Expand Down

0 comments on commit b19683e

Please sign in to comment.