mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2024-12-27 10:36:09 -07:00
Capture output of stdout and stderr to Actions (#30)
* Capture output of stdout and stderr to Actions
* Remove type descriptors
Whoops! This isn't typescript
* Remove semicolons
* Rename cmd to args
* Separate command from arguments to exec
* Revert "Rename cmd to args"
This reverts commit 98591e5513
.
* Append stdout and stderr to string, then log
* Consolidate stdout and stderr into single output
* Move base command back to cmd variable
* Embed execOptions as parameter to exec
This commit is contained in:
parent
fbcc2c2bae
commit
00e2fc8809
|
@ -31,6 +31,9 @@ inputs:
|
||||||
sudo:
|
sudo:
|
||||||
description: Set to "true" if root is required for running your playbook
|
description: Set to "true" if root is required for running your playbook
|
||||||
required: false
|
required: false
|
||||||
|
outputs:
|
||||||
|
output:
|
||||||
|
description: The captured output of both stdout and stderr from the Ansible Playbook run
|
||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
main: main.js
|
main: main.js
|
||||||
|
|
13
main.js
13
main.js
|
@ -81,7 +81,18 @@ async function main() {
|
||||||
|
|
||||||
process.env.ANSIBLE_FORCE_COLOR = "True"
|
process.env.ANSIBLE_FORCE_COLOR = "True"
|
||||||
|
|
||||||
await exec.exec(cmd.join(' '))
|
let output = ""
|
||||||
|
await exec.exec(cmd.join(' '), null, {
|
||||||
|
listeners: {
|
||||||
|
stdout: function(data) {
|
||||||
|
output += data.toString()
|
||||||
|
},
|
||||||
|
stderr: function(data) {
|
||||||
|
output += data.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
core.setOutput("output", output)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user