From 59c2f52f26f148f250992d33c10ea24373f758d3 Mon Sep 17 00:00:00 2001 From: wsargent-emcins <161492079+wsargent-emcins@users.noreply.github.com> Date: Tue, 25 Jun 2024 09:50:13 -0500 Subject: [PATCH] Refactor Main.ts to use Env Files --- src/main.ts | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main.ts b/src/main.ts index c587ca47..bd6a7ace 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,18 +1,26 @@ -import * as core from '@actions/core' -import fs from 'fs' -import util from 'util' +import * as core from '@actions/core'; +import fs from 'fs'; +import util from 'util'; async function run(): Promise { try { - const filePath = core.getInput('path') - const encoding = core.getInput('encoding') - const readFile = util.promisify(fs.readFile) - const contents = await readFile(filePath, encoding) - core.info(`File contents:\n${contents}`) - core.setOutput('contents', contents) + const filePath = core.getInput('path'); + const encoding = core.getInput('encoding'); + const readFile = util.promisify(fs.readFile); + const contents = await readFile(filePath, encoding); + core.info(`File contents:\n${contents}`); + + // Write to environment file + const outputFilePath = process.env.GITHUB_ENV || ''; + if (outputFilePath) { + const output = `contents<