diff --git a/action.yml b/action.yml index 18533b9..7e90219 100644 --- a/action.yml +++ b/action.yml @@ -15,3 +15,4 @@ inputs: runs: using: node12 main: main.js + post: post.js diff --git a/main.js b/main.js index ccc4b8d..3ac9d2e 100644 --- a/main.js +++ b/main.js @@ -78,6 +78,7 @@ async function main() { image, "sleep", "inf" ]) + core.saveState("container", container) core.endGroup() core.startGroup("Start container") diff --git a/post.js b/post.js new file mode 100644 index 0000000..1ab6f72 --- /dev/null +++ b/post.js @@ -0,0 +1,21 @@ +const core = require("@actions/core") +const exec = require("@actions/exec") + +async function main() { + try { + const container = core.getState("container") + core.saveState("container", "") + + if (container) { + await exec.exec("docker", [ + "rm", + "--force", + container + ]) + } + } catch (error) { + core.setFailed(error.message) + } +} + +main()