Skip to content

Commit 437e07d

Browse files
adds refactored copy of main
1 parent 5f25421 commit 437e07d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/main_env.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as core from '@actions/core';
2+
import fs from 'fs';
3+
import util from 'util';
4+
5+
async function run(): Promise<void> {
6+
try {
7+
const filePath = core.getInput('path');
8+
const encoding = core.getInput('encoding');
9+
const readFile = util.promisify(fs.readFile);
10+
const contents = await readFile(filePath, encoding);
11+
core.info(`File contents:\n${contents}`);
12+
13+
// Write to environment file
14+
const outputFilePath = process.env.GITHUB_ENV || '';
15+
if (outputFilePath) {
16+
const output = `contents<<EOF\n${contents}\nEOF`;
17+
await fs.promises.appendFile(outputFilePath, output + '\n');
18+
} else {
19+
core.warning('GITHUB_ENV not defined. Cannot write to environment file.');
20+
}
21+
} catch (error) {
22+
core.setFailed(error.message);
23+
}
24+
}
25+
26+
run();

0 commit comments

Comments
 (0)