File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ( ) ;
You can’t perform that action at this time.
0 commit comments