From 65519fdfa4c87dbc0c84598c59f54ea5fd7c3476 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 9 Dec 2020 23:06:47 +0100 Subject: [PATCH 1/3] action: add post run --- action.yml | 1 + 1 file changed, 1 insertion(+) 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 From 4d5a705a8db142155a13cf8b84d994ebe33f87be Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 9 Dec 2020 23:07:04 +0100 Subject: [PATCH 2/3] main: save container to state --- main.js | 1 + 1 file changed, 1 insertion(+) 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") From 75370c12a6f130e403e842fb3c35b696ad347816 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 9 Dec 2020 23:07:13 +0100 Subject: [PATCH 3/3] add post script --- post.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 post.js 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()