1
0
Fork 0
mirror of https://github.com/dawidd6/action-ansible-playbook.git synced 2024-11-26 02:11:30 +00:00

Capture output of stdout and stderr to Actions

This commit is contained in:
Brooks Swinnerton 2021-07-30 11:42:16 -04:00
parent fbcc2c2bae
commit d82d4c8f2c
No known key found for this signature in database
GPG key ID: 72743B7DE552E25A
2 changed files with 16 additions and 1 deletions

View file

@ -31,6 +31,11 @@ inputs:
sudo:
description: Set to "true" if root is required for running your playbook
required: false
outputs:
stdout:
description: The captured output of stdout from the Ansible Playbook run
stderr:
description: The captured output of stderr from the Ansible Playbook run
runs:
using: node12
main: main.js

12
main.js
View file

@ -81,7 +81,17 @@ async function main() {
process.env.ANSIBLE_FORCE_COLOR = "True"
await exec.exec(cmd.join(' '))
const execOptions = {};
execOptions.listeners = {
stdout: (data: Buffer) => {
core.setOutput('stdout', data.toString());
},
stderr: (data: Buffer) => {
core.setOutput('stderr', data.toString());
}
};
await exec.exec(cmd.join(' '), execOptions)
} catch (error) {
core.setFailed(error.message)
}