From c175cd3110dd317b6dec49a6eb463804727ec1ac Mon Sep 17 00:00:00 2001 From: Ronen Lubin <63970571+ronenlu@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:35:28 +0200 Subject: [PATCH] fix binary removal (#133) --- migrate/apply/dist/index.js | 10 ++++++---- migrate/lint/dist/index.js | 10 ++++++---- migrate/push/dist/index.js | 10 ++++++---- shim/index.js | 10 ++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/migrate/apply/dist/index.js b/migrate/apply/dist/index.js index 1d02ede..e712c0c 100644 --- a/migrate/apply/dist/index.js +++ b/migrate/apply/dist/index.js @@ -10488,12 +10488,14 @@ module.exports = async function run(action) { toolPath = toolCache.find('atlas-action', cacheVersion); if (!toolPath) { core.info(`Downloading atlas-action binary: ${url}`) - toolPath = await toolCache.downloadTool(url, 'atlas-action'); + // check if the binary is already in 'atlas-action' file + if (fs.existsSync('atlas-action')) { + toolPath = 'atlas-action'; + } else { + toolPath = await toolCache.downloadTool(url, 'atlas-action'); + } let cachedToolPath = await toolCache.cacheFile(toolPath, 'atlas-action', 'atlas-action', cacheVersion); core.addPath(cachedToolPath); - // Remove the downloaded binary - fs.unlinkSync(toolPath); - toolPath = cachedToolPath; } fs.chmodSync(toolPath, '700'); // Assuming the binary is directly within toolPath } diff --git a/migrate/lint/dist/index.js b/migrate/lint/dist/index.js index 1848055..c134111 100644 --- a/migrate/lint/dist/index.js +++ b/migrate/lint/dist/index.js @@ -10488,12 +10488,14 @@ module.exports = async function run(action) { toolPath = toolCache.find('atlas-action', cacheVersion); if (!toolPath) { core.info(`Downloading atlas-action binary: ${url}`) - toolPath = await toolCache.downloadTool(url, 'atlas-action'); + // check if the binary is already in 'atlas-action' file + if (fs.existsSync('atlas-action')) { + toolPath = 'atlas-action'; + } else { + toolPath = await toolCache.downloadTool(url, 'atlas-action'); + } let cachedToolPath = await toolCache.cacheFile(toolPath, 'atlas-action', 'atlas-action', cacheVersion); core.addPath(cachedToolPath); - // Remove the downloaded binary - fs.unlinkSync(toolPath); - toolPath = cachedToolPath; } fs.chmodSync(toolPath, '700'); // Assuming the binary is directly within toolPath } diff --git a/migrate/push/dist/index.js b/migrate/push/dist/index.js index 42b43bf..879ed93 100644 --- a/migrate/push/dist/index.js +++ b/migrate/push/dist/index.js @@ -10488,12 +10488,14 @@ module.exports = async function run(action) { toolPath = toolCache.find('atlas-action', cacheVersion); if (!toolPath) { core.info(`Downloading atlas-action binary: ${url}`) - toolPath = await toolCache.downloadTool(url, 'atlas-action'); + // check if the binary is already in 'atlas-action' file + if (fs.existsSync('atlas-action')) { + toolPath = 'atlas-action'; + } else { + toolPath = await toolCache.downloadTool(url, 'atlas-action'); + } let cachedToolPath = await toolCache.cacheFile(toolPath, 'atlas-action', 'atlas-action', cacheVersion); core.addPath(cachedToolPath); - // Remove the downloaded binary - fs.unlinkSync(toolPath); - toolPath = cachedToolPath; } fs.chmodSync(toolPath, '700'); // Assuming the binary is directly within toolPath } diff --git a/shim/index.js b/shim/index.js index 811406f..7e32be2 100644 --- a/shim/index.js +++ b/shim/index.js @@ -36,12 +36,14 @@ module.exports = async function run(action) { toolPath = toolCache.find('atlas-action', cacheVersion); if (!toolPath) { core.info(`Downloading atlas-action binary: ${url}`) - toolPath = await toolCache.downloadTool(url, 'atlas-action'); + // check if the binary is already in 'atlas-action' file + if (fs.existsSync('atlas-action')) { + toolPath = 'atlas-action'; + } else { + toolPath = await toolCache.downloadTool(url, 'atlas-action'); + } let cachedToolPath = await toolCache.cacheFile(toolPath, 'atlas-action', 'atlas-action', cacheVersion); core.addPath(cachedToolPath); - // Remove the downloaded binary - fs.unlinkSync(toolPath); - toolPath = cachedToolPath; } fs.chmodSync(toolPath, '700'); // Assuming the binary is directly within toolPath }