Skip to content

Commit f907cd8

Browse files
committed
fix: require push=always for mergeTag, validate mutual exclusion with platformTag
- Fail early with a clear error if mergeTag is set without push: always, preventing silent no-ops when default push filtering skips the manifest. - Fail early if both mergeTag and platformTag are set on the same step. - Simplify redundant return logic in mergeTag runPost blocks. - Add push: always to manifest job examples in docs.
1 parent 655be62 commit f907cd8

5 files changed

Lines changed: 50 additions & 16 deletions

File tree

azdo-task/DevcontainersCi/src/main.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,25 @@ export async function runMain(): Promise<void> {
2626
task.setTaskVariable('hasRunMain', 'true');
2727

2828
const mergeTag = task.getInput('mergeTag');
29+
const platformTag = task.getInput('platformTag');
30+
31+
if (mergeTag && platformTag) {
32+
task.setResult(
33+
task.TaskResult.Failed,
34+
'mergeTag and platformTag cannot be used together - mergeTag is for the manifest merge job, platformTag is for per-platform build jobs',
35+
);
36+
return;
37+
}
38+
2939
if (mergeTag) {
40+
const pushOption = task.getInput('push');
41+
if (pushOption !== 'always') {
42+
task.setResult(
43+
task.TaskResult.Failed,
44+
"push must be set to 'always' when using mergeTag - the manifest merge job must push the resulting multi-arch image",
45+
);
46+
return;
47+
}
3048
console.log(
3149
'mergeTag is set - skipping build (manifest merge will run in post step)',
3250
);
@@ -58,7 +76,6 @@ export async function runMain(): Promise<void> {
5876
const imageName = task.getInput('imageName');
5977
const imageTag = task.getInput('imageTag');
6078
const platform = task.getInput('platform');
61-
const platformTag = task.getInput('platformTag');
6279
const subFolder = task.getInput('subFolder') ?? '.';
6380
const relativeConfigFile = task.getInput('configFile');
6481
const runCommand = task.getInput('runCmd');
@@ -291,16 +308,13 @@ export async function runPost(): Promise<void> {
291308
const imageTagArray = imageTag.split(/\s*,\s*/);
292309

293310
if (mergeTag) {
294-
const success = await mergeMultiPlatformImages(
311+
await mergeMultiPlatformImages(
295312
imageName,
296313
imageTagArray,
297314
mergeTag,
298315
createMultiPlatformImage,
299316
(msg: string) => console.log(msg),
300317
);
301-
if (!success) {
302-
return;
303-
}
304318
return;
305319
}
306320

docs/multi-platform-builds.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ jobs:
128128
with:
129129
imageName: ghcr.io/example/myimage
130130
mergeTag: linux-amd64,linux-arm64
131+
push: always
131132
```
132133
133134
### Azure DevOps Pipelines Example
@@ -169,4 +170,5 @@ stages:
169170
inputs:
170171
imageName: myregistry.azurecr.io/devcontainer
171172
mergeTag: linux-amd64,linux-arm64
173+
push: always
172174
```

github-action/dist/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,17 @@ function runMain() {
21662166
core.info('Starting...');
21672167
core.saveState('hasRunMain', 'true');
21682168
const mergeTag = emptyStringAsUndefined(core.getInput('mergeTag'));
2169+
const platformTag = emptyStringAsUndefined(core.getInput('platformTag'));
2170+
if (mergeTag && platformTag) {
2171+
core.setFailed('mergeTag and platformTag cannot be used together - mergeTag is for the manifest merge job, platformTag is for per-platform build jobs');
2172+
return;
2173+
}
21692174
if (mergeTag) {
2175+
const pushOption = emptyStringAsUndefined(core.getInput('push'));
2176+
if (pushOption !== 'always') {
2177+
core.setFailed("push must be set to 'always' when using mergeTag - the manifest merge job must push the resulting multi-arch image");
2178+
return;
2179+
}
21702180
core.info('mergeTag is set - skipping build (manifest merge will run in post step)');
21712181
core.saveState('mergeTag', mergeTag);
21722182
return;
@@ -2189,7 +2199,6 @@ function runMain() {
21892199
const imageName = emptyStringAsUndefined(core.getInput('imageName'));
21902200
const imageTag = emptyStringAsUndefined(core.getInput('imageTag'));
21912201
const platform = emptyStringAsUndefined(core.getInput('platform'));
2192-
const platformTag = emptyStringAsUndefined(core.getInput('platformTag'));
21932202
const subFolder = core.getInput('subFolder');
21942203
const relativeConfigFile = emptyStringAsUndefined(core.getInput('configFile'));
21952204
const runCommand = core.getInput('runCmd');
@@ -2378,10 +2387,7 @@ function runPost() {
23782387
return;
23792388
}
23802389
if (mergeTag) {
2381-
const success = yield (0, platform_1.mergeMultiPlatformImages)(imageName, imageTagArray, mergeTag, docker_1.createMultiPlatformImage, (msg) => core.info(msg));
2382-
if (!success) {
2383-
return;
2384-
}
2390+
yield (0, platform_1.mergeMultiPlatformImages)(imageName, imageTagArray, mergeTag, docker_1.createMultiPlatformImage, (msg) => core.info(msg));
23852391
return;
23862392
}
23872393
const platform = emptyStringAsUndefined(core.getInput('platform'));

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: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,23 @@ export async function runMain(): Promise<void> {
3636
core.saveState('hasRunMain', 'true');
3737

3838
const mergeTag = emptyStringAsUndefined(core.getInput('mergeTag'));
39+
const platformTag = emptyStringAsUndefined(core.getInput('platformTag'));
40+
41+
if (mergeTag && platformTag) {
42+
core.setFailed(
43+
'mergeTag and platformTag cannot be used together - mergeTag is for the manifest merge job, platformTag is for per-platform build jobs',
44+
);
45+
return;
46+
}
47+
3948
if (mergeTag) {
49+
const pushOption = emptyStringAsUndefined(core.getInput('push'));
50+
if (pushOption !== 'always') {
51+
core.setFailed(
52+
"push must be set to 'always' when using mergeTag - the manifest merge job must push the resulting multi-arch image",
53+
);
54+
return;
55+
}
4056
core.info(
4157
'mergeTag is set - skipping build (manifest merge will run in post step)',
4258
);
@@ -65,7 +81,6 @@ export async function runMain(): Promise<void> {
6581
const imageName = emptyStringAsUndefined(core.getInput('imageName'));
6682
const imageTag = emptyStringAsUndefined(core.getInput('imageTag'));
6783
const platform = emptyStringAsUndefined(core.getInput('platform'));
68-
const platformTag = emptyStringAsUndefined(core.getInput('platformTag'));
6984
const subFolder: string = core.getInput('subFolder');
7085
const relativeConfigFile = emptyStringAsUndefined(
7186
core.getInput('configFile'),
@@ -293,16 +308,13 @@ export async function runPost(): Promise<void> {
293308
}
294309

295310
if (mergeTag) {
296-
const success = await mergeMultiPlatformImages(
311+
await mergeMultiPlatformImages(
297312
imageName,
298313
imageTagArray,
299314
mergeTag,
300315
createMultiPlatformImage,
301316
(msg: string) => core.info(msg),
302317
);
303-
if (!success) {
304-
return;
305-
}
306318
return;
307319
}
308320

0 commit comments

Comments
 (0)