mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2024-11-22 07:26:25 +00:00
main: parse requirements yaml and run appropriate commands
This commit is contained in:
parent
19d1b2c628
commit
9a7cbd2b6b
1 changed files with 12 additions and 2 deletions
14
main.js
14
main.js
|
@ -1,5 +1,6 @@
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const exec = require('@actions/exec')
|
const exec = require('@actions/exec')
|
||||||
|
const yaml = require('yaml')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
|
|
||||||
|
@ -25,8 +26,17 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requirements) {
|
if (requirements) {
|
||||||
await exec.exec("ansible-galaxy", ["role", "install", "-r", requirements])
|
const requirementsContent = fs.readFileSync(requirements, 'utf8')
|
||||||
await exec.exec("ansible-galaxy", ["collection", "install", "-r", requirements])
|
const requirementsObject = yaml.parse(requirementsContent)
|
||||||
|
|
||||||
|
if (Array.isArray(requirementsObject)) {
|
||||||
|
await exec.exec("ansible-galaxy", ["install", "-r", requirements])
|
||||||
|
} else {
|
||||||
|
if (requirementsObject.roles)
|
||||||
|
await exec.exec("ansible-galaxy", ["role", "install", "-r", requirements])
|
||||||
|
if (requirementsObject.collections)
|
||||||
|
await exec.exec("ansible-galaxy", ["collection", "install", "-r", requirements])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
|
|
Loading…
Reference in a new issue