From 8a5a01ff3cfcf8572aef2b1fe4afcf2be1f47403 Mon Sep 17 00:00:00 2001 From: "Anantachai Saothong (Manta)" Date: Thu, 19 Oct 2023 19:46:36 +0700 Subject: [PATCH] test --- out/main.js | 16 ++++++++++++---- out/post.js | 1 + src/main.ts | 13 +++++++++++-- src/post.ts | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/out/main.js b/out/main.js index 9f2a574..1159dd0 100644 --- a/out/main.js +++ b/out/main.js @@ -17773,11 +17773,11 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); command_1.issue("echo", enabled ? "on" : "off"); } exports.setCommandEcho = setCommandEcho; - function setFailed(message) { + function setFailed2(message) { process.exitCode = ExitCode.Failure; error(message); } - exports.setFailed = setFailed; + exports.setFailed = setFailed2; function isDebug() { return process.env["RUNNER_DEBUG"] === "1"; } @@ -73865,8 +73865,16 @@ var cache = __toESM(require_cache2()); (async () => { const resultFilePath = "/tmp/result.json"; core.saveState("result-file-path", resultFilePath); - const found = !!await cache.restoreCache([resultFilePath], core.getInput("cache-key")); - core.setOutput("cache-hit", found); + const cacheHit = !!await cache.restoreCache([resultFilePath], core.getInput("cache-key")); + console.log("cache-hit =", cacheHit); + core.setOutput("cache-hit", cacheHit); + if (cacheHit) { + const result = require(resultFilePath); + console.log("result =", result); + if (result.status === "failure") { + core.setFailed("This job has been failed at " + result.url); + } + } })(); /*! Bundled license information: diff --git a/out/post.js b/out/post.js index a89b2f2..669980a 100644 --- a/out/post.js +++ b/out/post.js @@ -78023,6 +78023,7 @@ var mkdirp = Object.assign(async (path2, opts) => { // src/post.ts (async () => { const api = github.getOctokit(core.getInput("github-token")); + console.log("job_id =", github.context.job); const { data: job } = await api.rest.actions.getJobForWorkflowRun({ ...github.context.repo, job_id: Number(github.context.job) diff --git a/src/main.ts b/src/main.ts index a464042..383c67e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,7 +7,16 @@ void 0; const resultFilePath = '/tmp/result.json' core.saveState('result-file-path', resultFilePath) - const found = !!(await cache.restoreCache([resultFilePath], core.getInput('cache-key'))) + const cacheHit = !!(await cache.restoreCache([resultFilePath], core.getInput('cache-key'))) - core.setOutput('cache-hit', found) + console.log('cache-hit =', cacheHit) + core.setOutput('cache-hit', cacheHit) + + if (cacheHit) { + const result = require(resultFilePath) + console.log('result =', result) + if (result.status === 'failure') { + core.setFailed('This job has been failed at ' + result.url) + } + } })() diff --git a/src/post.ts b/src/post.ts index f8e7aec..4e44da1 100644 --- a/src/post.ts +++ b/src/post.ts @@ -10,6 +10,7 @@ void 0; (async () => { const api = github.getOctokit(core.getInput('github-token')) + console.log('job_id =', github.context.job) const { data: job } = await api.rest.actions.getJobForWorkflowRun({ ...github.context.repo, job_id: Number(github.context.job),