import * as core from '@actions/core' ; import fs from 'fs' ; async function checkExistence ( path ) { try { await fs . promises . access ( path ) ; } catch ( error ) { return false ; } return true ; } async function run ( ) { try { const files = core . getInput ( 'files' , { required : true } ) ; const failure = ( core . getInput ( 'allow_failure' ) || 'false' ) . toUpperCase ( ) === 'TRUE' ; const fileList = files . split ( ',' ) . map ( ( item ) => item . trim ( ) ) ; const missingFiles = [ ] ; await Promise . all ( fileList . map ( async ( file ) => { const isPresent = await checkExistence ( file ) ; if ( ! isPresent ) { missingFiles . push ( file ) ; } } ) ) ; if ( missingFiles . length > 0 ) { if ( failure ) { core . setFailed ( `These files doesn't exist: ${ missingFiles . join ( ', ' ) }` ) ; } else { core . info ( `These files doesn't exist: ${ missingFiles . join ( ', ' ) }` ) ; } core . setOutput ( 'files_exists' , 'false' ) ; } else { core . info ( '🎉 All files exists' ) ; core . setOutput ( 'files_exists' , 'true' ) ; } } catch ( error ) { core . setFailed ( error . message ) ; } } run ( ) ;