Skip to content

Commit

Permalink
adds refactored copy of main
Browse files Browse the repository at this point in the history
  • Loading branch information
wsargent-emcins committed Jun 25, 2024
1 parent 5f25421 commit 437e07d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main_env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as core from '@actions/core';
import fs from 'fs';
import util from 'util';

async function run(): Promise<void> {
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}`);

// Write to environment file
const outputFilePath = process.env.GITHUB_ENV || '';
if (outputFilePath) {
const output = `contents<<EOF\n${contents}\nEOF`;
await fs.promises.appendFile(outputFilePath, output + '\n');
} else {
core.warning('GITHUB_ENV not defined. Cannot write to environment file.');
}
} catch (error) {
core.setFailed(error.message);
}
}

run();

0 comments on commit 437e07d

Please sign in to comment.