action-ansible-playbook/post.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-05-07 03:41:40 -06:00
const core = require('@actions/core')
const fs = require('fs')
function rm(file) {
if (fs.existsSync(file)) {
2022-09-01 00:37:48 -06:00
core.info(`Deleting "${file}" file`)
fs.unlinkSync(file)
}
2020-05-07 03:41:40 -06:00
}
async function main() {
try {
2020-05-14 12:16:43 -06:00
const directory = core.getState("directory")
const ansibleConfigurationFile = core.getState("ansibleConfigurationFile")
2020-05-07 03:41:40 -06:00
const keyFile = core.getState("keyFile")
const inventoryFile = core.getState("inventoryFile")
const vaultPasswordFile = core.getState("vaultPasswordFile")
const knownHostsFile = core.getState("knownHostsFile")
2020-05-07 03:41:40 -06:00
2020-05-14 12:16:43 -06:00
if (directory)
process.chdir(directory)
if (ansibleConfigurationFile)
rm(ansibleConfigurationFile)
2020-05-14 12:16:43 -06:00
2020-05-07 03:41:40 -06:00
if (keyFile)
rm(keyFile)
if (inventoryFile)
rm(inventoryFile)
if (vaultPasswordFile)
rm(vaultPasswordFile)
if (knownHostsFile)
rm(knownHostsFile)
2020-05-07 03:41:40 -06:00
} catch (error) {
core.setFailed(error.message)
}
}
main()