@@ -111,12 +111,18 @@ export async function runMain(): Promise<void> {
111111 if ( imageName ) {
112112 if ( fullImageNameArray . length === 1 ) {
113113 if ( ! noCache && ! cacheFrom . includes ( fullImageNameArray [ 0 ] ) ) {
114+ // If the cacheFrom options don't include the fullImageName, add it here
115+ // This ensures that when building a PR where the image specified in the action
116+ // isn't included in devcontainer.json (or docker-compose.yml), the action still
117+ // resolves a previous image for the tag as a layer cache (if pushed to a registry)
118+
114119 core . info (
115120 `Adding --cache-from ${ fullImageNameArray [ 0 ] } to build args` ,
116121 ) ;
117122 cacheFrom . splice ( 0 , 0 , fullImageNameArray [ 0 ] ) ;
118123 }
119124 } else {
125+ // Don't automatically add --cache-from if multiple image tags are specified
120126 core . info (
121127 'Not adding --cache-from automatically since multiple image tags were supplied' ,
122128 ) ;
@@ -255,15 +261,18 @@ export async function runPost(): Promise<void> {
255261
256262 const platformTag = emptyStringAsUndefined ( core . getState ( 'platformTag' ) ) ;
257263
264+ // default to 'never' if not set and no imageName
258265 if ( pushOption === 'never' || ( ! pushOption && ! imageName ) ) {
259266 core . info ( `Image push skipped because 'push' is set to '${ pushOption } '` ) ;
260267 return ;
261268 }
262269
270+ // default to 'filter' if not set and imageName is set
263271 if ( pushOption === 'filter' || ( ! pushOption && imageName ) ) {
272+ // https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
264273 const ref = process . env . GITHUB_REF ;
265274 if (
266- refFilterForPush . length !== 0 &&
275+ refFilterForPush . length !== 0 && // empty filter allows all
267276 ! refFilterForPush . some ( s => s === ref )
268277 ) {
269278 core . info (
@@ -273,7 +282,7 @@ export async function runPost(): Promise<void> {
273282 }
274283 const eventName = process . env . GITHUB_EVENT_NAME ;
275284 if (
276- eventFilterForPush . length !== 0 &&
285+ eventFilterForPush . length !== 0 && // empty filter allows all
277286 ! eventFilterForPush . some ( s => s === eventName )
278287 ) {
279288 core . info (
@@ -291,6 +300,7 @@ export async function runPost(): Promise<void> {
291300 const imageTagArray = imageTag . split ( / \s * , \s * / ) ;
292301 if ( ! imageName ) {
293302 if ( pushOption ) {
303+ // pushOption was set (and not to "never") - give an error that imageName is required
294304 core . error ( 'imageName is required to push images' ) ;
295305 }
296306 return ;
0 commit comments