File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed
Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,41 @@ describe("extractSecret", () => {
106106 ) ;
107107 expect ( core . setSecret ) . toHaveBeenCalledWith ( testSecretValue ) ;
108108 } ) ;
109+
110+ describe ( "when secret value is empty string" , ( ) => {
111+ const emptySecretValue = "" ;
112+
113+ beforeEach ( ( ) => {
114+ ( read . parse as jest . Mock ) . mockReturnValue ( emptySecretValue ) ;
115+ } ) ;
116+
117+ afterEach ( ( ) => {
118+ ( read . parse as jest . Mock ) . mockReturnValue ( testSecretValue ) ;
119+ } ) ;
120+
121+ it ( "should set empty string as step output" , ( ) => {
122+ extractSecret ( envTestSecretEnv , false ) ;
123+ expect ( core . setOutput ) . toHaveBeenCalledWith (
124+ envTestSecretEnv ,
125+ emptySecretValue ,
126+ ) ;
127+ expect ( core . exportVariable ) . not . toHaveBeenCalled ( ) ;
128+ } ) ;
129+
130+ it ( "should set empty string as environment variable" , ( ) => {
131+ extractSecret ( envTestSecretEnv , true ) ;
132+ expect ( core . exportVariable ) . toHaveBeenCalledWith (
133+ envTestSecretEnv ,
134+ emptySecretValue ,
135+ ) ;
136+ expect ( core . setOutput ) . not . toHaveBeenCalled ( ) ;
137+ } ) ;
138+
139+ it ( "should not call setSecret for empty string" , ( ) => {
140+ extractSecret ( envTestSecretEnv , false ) ;
141+ expect ( core . setSecret ) . not . toHaveBeenCalled ( ) ;
142+ } ) ;
143+ } ) ;
109144} ) ;
110145
111146describe ( "loadSecrets" , ( ) => {
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export const extractSecret = (
4141 }
4242
4343 const secretValue = read . parse ( ref ) ;
44- if ( ! secretValue ) {
44+ if ( secretValue === null || secretValue === undefined ) {
4545 return ;
4646 }
4747
@@ -50,7 +50,11 @@ export const extractSecret = (
5050 } else {
5151 core . setOutput ( envName , secretValue ) ;
5252 }
53- core . setSecret ( secretValue ) ;
53+ // Skip setSecret for empty strings to avoid the warning:
54+ // "Can't add secret mask for empty string in ##[add-mask] command."
55+ if ( secretValue ) {
56+ core . setSecret ( secretValue ) ;
57+ }
5458} ;
5559
5660export const loadSecrets = async ( shouldExportEnv : boolean ) : Promise < void > => {
You can’t perform that action at this time.
0 commit comments