From 32f94abf82a7dee0871f09cfea8e00e7d49c5dfd Mon Sep 17 00:00:00 2001 From: Volodymyr Zotov Date: Wed, 30 Jul 2025 12:49:44 -0500 Subject: [PATCH] Write to GITHUB_ENV manually --- configure/dist/index.js | 27 +++++++++++++++++++-------- configure/index.js | 27 +++++++++++++++++++-------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/configure/dist/index.js b/configure/dist/index.js index fcdd3d1..b77131e 100644 --- a/configure/dist/index.js +++ b/configure/dist/index.js @@ -27555,8 +27555,13 @@ module.exports = parseParams /******/ /************************************************************************/ var __webpack_exports__ = {}; +const fs = __nccwpck_require__(9896); +const os = __nccwpck_require__(857); const core = __nccwpck_require__(7484); +// configure manually appends env vars to GITHUB_ENV variable +// We cannot use `core.exportVariable` because it will set env var for the current process +// therefore those env vars will not be available for the next steps in the workflow const configure = () => { const OP_CONNECT_HOST = process.env.INPUT_CONNECT_HOST || process.env.OP_CONNECT_HOST; @@ -27565,18 +27570,24 @@ const configure = () => { const OP_SERVICE_ACCOUNT_TOKEN = process.env.INPUT_SERVICE_ACCOUNT_TOKEN || process.env.SERVICE_ACCOUNT_TOKEN; + const githubEnvPath = process.env["GITHUB_ENV"]; - if (OP_CONNECT_HOST) { - core.exportVariable("OP_CONNECT_HOST", OP_CONNECT_HOST); + if (!githubEnvPath) { + core.setFailed("GITHUB_ENV is not defined"); + return; } - if (OP_CONNECT_TOKEN) { - core.exportVariable("OP_CONNECT_TOKEN", OP_CONNECT_TOKEN); - } + const setEnv = (key, value) => { + if (value) { + fs.appendFileSync(githubEnvPath, `${key}=${value}${os.EOL}`, { + encoding: "utf8", + }); + } + }; - if (OP_SERVICE_ACCOUNT_TOKEN) { - core.exportVariable("OP_SERVICE_ACCOUNT_TOKEN", OP_SERVICE_ACCOUNT_TOKEN); - } + setEnv("OP_CONNECT_HOST", OP_CONNECT_HOST); + setEnv("OP_CONNECT_TOKEN", OP_CONNECT_TOKEN); + setEnv("OP_SERVICE_ACCOUNT_TOKEN", OP_SERVICE_ACCOUNT_TOKEN); }; configure(); diff --git a/configure/index.js b/configure/index.js index d21d46f..4917fed 100644 --- a/configure/index.js +++ b/configure/index.js @@ -1,5 +1,10 @@ +const fs = require("fs"); +const os = require("os"); const core = require("@actions/core"); +// configure manually appends env vars to GITHUB_ENV variable +// We cannot use `core.exportVariable` because it will set env var for the current process +// therefore those env vars will not be available for the next steps in the workflow const configure = () => { const OP_CONNECT_HOST = process.env.INPUT_CONNECT_HOST || process.env.OP_CONNECT_HOST; @@ -8,18 +13,24 @@ const configure = () => { const OP_SERVICE_ACCOUNT_TOKEN = process.env.INPUT_SERVICE_ACCOUNT_TOKEN || process.env.SERVICE_ACCOUNT_TOKEN; + const githubEnvPath = process.env["GITHUB_ENV"]; - if (OP_CONNECT_HOST) { - core.exportVariable("OP_CONNECT_HOST", OP_CONNECT_HOST); + if (!githubEnvPath) { + core.setFailed("GITHUB_ENV is not defined"); + return; } - if (OP_CONNECT_TOKEN) { - core.exportVariable("OP_CONNECT_TOKEN", OP_CONNECT_TOKEN); - } + const setEnv = (key, value) => { + if (value) { + fs.appendFileSync(githubEnvPath, `${key}=${value}${os.EOL}`, { + encoding: "utf8", + }); + } + }; - if (OP_SERVICE_ACCOUNT_TOKEN) { - core.exportVariable("OP_SERVICE_ACCOUNT_TOKEN", OP_SERVICE_ACCOUNT_TOKEN); - } + setEnv("OP_CONNECT_HOST", OP_CONNECT_HOST); + setEnv("OP_CONNECT_TOKEN", OP_CONNECT_TOKEN); + setEnv("OP_SERVICE_ACCOUNT_TOKEN", OP_SERVICE_ACCOUNT_TOKEN); }; configure();