Skip to content

Commit 1772e73

Browse files
committed
fix: restore upstream comments removed during feature implementation
1 parent c959376 commit 1772e73

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

github-action/dist/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,11 +2235,16 @@ function runMain() {
22352235
if (imageName) {
22362236
if (fullImageNameArray.length === 1) {
22372237
if (!noCache && !cacheFrom.includes(fullImageNameArray[0])) {
2238+
// If the cacheFrom options don't include the fullImageName, add it here
2239+
// This ensures that when building a PR where the image specified in the action
2240+
// isn't included in devcontainer.json (or docker-compose.yml), the action still
2241+
// resolves a previous image for the tag as a layer cache (if pushed to a registry)
22382242
core.info(`Adding --cache-from ${fullImageNameArray[0]} to build args`);
22392243
cacheFrom.splice(0, 0, fullImageNameArray[0]);
22402244
}
22412245
}
22422246
else {
2247+
// Don't automatically add --cache-from if multiple image tags are specified
22432248
core.info('Not adding --cache-from automatically since multiple image tags were supplied');
22442249
}
22452250
}
@@ -2365,19 +2370,22 @@ function runPost() {
23652370
return;
23662371
}
23672372
const platformTag = emptyStringAsUndefined(core.getState('platformTag'));
2373+
// default to 'never' if not set and no imageName
23682374
if (pushOption === 'never' || (!pushOption && !imageName)) {
23692375
core.info(`Image push skipped because 'push' is set to '${pushOption}'`);
23702376
return;
23712377
}
2378+
// default to 'filter' if not set and imageName is set
23722379
if (pushOption === 'filter' || (!pushOption && imageName)) {
2380+
// https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
23732381
const ref = process.env.GITHUB_REF;
2374-
if (refFilterForPush.length !== 0 &&
2382+
if (refFilterForPush.length !== 0 && // empty filter allows all
23752383
!refFilterForPush.some(s => s === ref)) {
23762384
core.info(`Image push skipped because GITHUB_REF (${ref}) is not in refFilterForPush`);
23772385
return;
23782386
}
23792387
const eventName = process.env.GITHUB_EVENT_NAME;
2380-
if (eventFilterForPush.length !== 0 &&
2388+
if (eventFilterForPush.length !== 0 && // empty filter allows all
23812389
!eventFilterForPush.some(s => s === eventName)) {
23822390
core.info(`Image push skipped because GITHUB_EVENT_NAME (${eventName}) is not in eventFilterForPush`);
23832391
return;
@@ -2391,6 +2399,7 @@ function runPost() {
23912399
const imageTagArray = imageTag.split(/\s*,\s*/);
23922400
if (!imageName) {
23932401
if (pushOption) {
2402+
// pushOption was set (and not to "never") - give an error that imageName is required
23942403
core.error('imageName is required to push images');
23952404
}
23962405
return;

github-action/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github-action/src/main.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)