@@ -569,6 +569,30 @@ async function downloadCacheWithTime(
569569 return { trapCaches, trapCacheDownloadTime } ;
570570}
571571
572+ /**
573+ * Amends the input config file if configInput is provided.
574+ * If configInput is set, it takes precedence over configFile.
575+ *
576+ * This function should be called only once on any specific `InitConfigInputs`
577+ * object. Otherwise it could emit a false warning.
578+ */
579+ export function amendInputConfigFile (
580+ inputs : InitConfigInputs ,
581+ logger : Logger ,
582+ ) : void {
583+ // if configInput is set, it takes precedence over configFile
584+ if ( inputs . configInput ) {
585+ if ( inputs . configFile ) {
586+ logger . warning (
587+ `Both a config file and config input were provided. Ignoring config file.` ,
588+ ) ;
589+ }
590+ inputs . configFile = userConfigFromActionPath ( inputs . tempDir ) ;
591+ fs . writeFileSync ( inputs . configFile , inputs . configInput ) ;
592+ logger . debug ( `Using config from action input: ${ inputs . configFile } ` ) ;
593+ }
594+ }
595+
572596async function loadUserConfig (
573597 configFile : string ,
574598 workspacePath : string ,
@@ -839,18 +863,6 @@ export async function initConfig(
839863) : Promise < Config > {
840864 const { logger, tempDir } = inputs ;
841865
842- // if configInput is set, it takes precedence over configFile
843- if ( inputs . configInput ) {
844- if ( inputs . configFile ) {
845- logger . warning (
846- `Both a config file and config input were provided. Ignoring config file.` ,
847- ) ;
848- }
849- inputs . configFile = userConfigFromActionPath ( tempDir ) ;
850- fs . writeFileSync ( inputs . configFile , inputs . configInput ) ;
851- logger . debug ( `Using config from action input: ${ inputs . configFile } ` ) ;
852- }
853-
854866 let userConfig : UserConfig = { } ;
855867 if ( ! inputs . configFile ) {
856868 logger . debug ( "No configuration file was provided" ) ;
0 commit comments