@@ -71,15 +71,93 @@ async function run(): Promise<void> {
7171 await miseLs ( )
7272 const loadEnv = core . getBooleanInput ( 'env' )
7373 if ( loadEnv ) {
74- const output = await exec . getExecOutput ( 'mise' , [ 'env' , '--dotenv' ] )
75- fs . appendFileSync ( process . env . GITHUB_ENV ! , output . stdout )
74+ await exportMiseEnv ( )
7675 }
7776 } catch ( err ) {
7877 if ( err instanceof Error ) core . setFailed ( err . message )
7978 else throw err
8079 }
8180}
8281
82+ async function exportMiseEnv ( ) : Promise < void > {
83+ core . startGroup ( 'Exporting mise environment variables' )
84+
85+ // Check if mise supports --redacted flags based on version input
86+ const supportsRedacted = checkMiseSupportsRedacted ( )
87+
88+ if ( supportsRedacted ) {
89+ try {
90+ // First, get the redacted values to identify what needs masking
91+ const redactedOutput = await exec . getExecOutput (
92+ 'mise' ,
93+ [ 'env' , '--redacted' , '--json' ] ,
94+ { silent : true }
95+ )
96+ const redactedVars = JSON . parse ( redactedOutput . stdout )
97+
98+ // Mask sensitive values in GitHub Actions
99+ for ( const [ key , actualValue ] of Object . entries ( redactedVars ) ) {
100+ core . setSecret ( actualValue as string )
101+ core . info ( `Masked sensitive value for: ${ key } ` )
102+ }
103+
104+ // Then get the actual values
105+ const actualOutput = await exec . getExecOutput ( 'mise' , [ 'env' , '--json' ] )
106+ const actualVars = JSON . parse ( actualOutput . stdout )
107+
108+ // Export all environment variables
109+ for ( const [ key , value ] of Object . entries ( actualVars ) ) {
110+ if ( typeof value === 'string' ) {
111+ core . exportVariable ( key , value )
112+ }
113+ }
114+ } catch {
115+ // Fall back to dotenv format if the redacted command fails
116+ core . info ( 'Falling back to dotenv format' )
117+ const output = await exec . getExecOutput ( 'mise' , [ 'env' , '--dotenv' ] )
118+ fs . appendFileSync ( process . env . GITHUB_ENV ! , output . stdout )
119+ }
120+ } else {
121+ // Fall back to the old --dotenv format for older versions
122+ const output = await exec . getExecOutput ( 'mise' , [ 'env' , '--dotenv' ] )
123+ fs . appendFileSync ( process . env . GITHUB_ENV ! , output . stdout )
124+ }
125+
126+ core . endGroup ( )
127+ }
128+
129+ function checkMiseSupportsRedacted ( ) : boolean {
130+ const version = core . getInput ( 'version' )
131+
132+ // If no version is specified, assume latest which supports redacted
133+ if ( ! version ) {
134+ return true
135+ }
136+
137+ // Parse the version string (remove 'v' prefix if present)
138+ const cleanVersion = version . replace ( / ^ v / , '' )
139+ const versionMatch = cleanVersion . match ( / ^ ( \d + ) \. ( \d + ) \. ( \d + ) / )
140+
141+ if ( ! versionMatch ) {
142+ // If we can't parse the version, assume it supports redacted
143+ return true
144+ }
145+
146+ const [ , year , month , patch ] = versionMatch
147+ const yearNum = parseInt ( year , 10 )
148+ const monthNum = parseInt ( month , 10 )
149+ const patchNum = parseInt ( patch , 10 )
150+
151+ // Check if version is >= 2025.8.17
152+ if ( yearNum > 2025 ) return true
153+ if ( yearNum === 2025 ) {
154+ if ( monthNum > 8 ) return true
155+ if ( monthNum === 8 && patchNum >= 17 ) return true
156+ }
157+
158+ return false
159+ }
160+
83161async function setEnvVars ( ) : Promise < void > {
84162 core . startGroup ( 'Setting env vars' )
85163 const set = ( k : string , v : string ) : void => {
0 commit comments