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'
1+ import * as core from '@actions/core' ;
2+ import fs from 'fs' ;
3+ import util from 'util' ;
44
55async function run ( ) : Promise < void > {
66 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- core . setOutput ( 'contents' , contents )
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+ }
1321 } catch ( error ) {
14- core . setFailed ( error . message )
22+ core . setFailed ( error . message ) ;
1523 }
1624}
1725
18- run ( )
26+ run ( ) ;
You can’t perform that action at this time.
0 commit comments