@@ -109,35 +109,43 @@ jobs:
109109 `"annotations.org.opencontainers.image.url" output is not valid`
110110 );
111111
112+ const expectedTags = [];
113+ let expectedImageVersion;
112114 if (`${{ github.event_name }}` === "pull_request") {
113115 const shortSha = `${{ github.sha }}`.substring(0, 7);
114116 const prShaTag = `pr-${{ github.event.pull_request.number }}-${shortSha}`;
115117 const prTag = `pr-${{ github.event.pull_request.number }}`;
116118
117- assert.equal(builtImage.tags.length, 2, `"tags" output is not valid`);
118-
119- assert.equal(builtImage.tags[0], prShaTag, `"tags" output is not valid`);
120- assert.equal(builtImage.tags[1], prTag, `"tags" output is not valid`);
121-
122- assert.equal(
123- builtImage.annotations["org.opencontainers.image.version"],
124- prTag,
125- `"annotations.org.opencontainers.image.version" output is not valid`
126- );
119+ expectedTags.push(prShaTag, prTag);
120+ expectedImageVersion = prShaTag;
127121 } else {
128122 const refTag = `${{ github.ref_name }}`;
123+ expectedTags.push(refTag);
124+ expectedImageVersion = refTag;
129125
130- assert.equal(builtImage.tags.length, 2, `"tags" output is not valid`);
131- assert.equal(builtImage.tags[0], refTag, `"tags" output is not valid`);
132- assert.equal(builtImage.tags[1], "latest", `"tags" output is not valid`);
126+ if (`${{ github.event_name }}` !== "workflow_dispatch") {
127+ expectedTags.push("latest");
128+ }
129+ }
133130
134- assert.equal(
135- builtImage.annotations["org.opencontainers.image.version"],
136- refTag,
137- `"annotations.org.opencontainers.image.version" output is not valid`
138- );
131+ assert.equal(
132+ builtImage.tags.length,
133+ expectedTags.length,
134+ `"tags" output is not valid, expected ${expectedTags.length} tags but got ${builtImage.tags.length}`
135+ );
136+
137+ for (const expectedTag of expectedTags) {
138+ if (!builtImage.tags.includes(expectedTag)) {
139+ assert.fail(`Expected tag "${expectedTag}" not found in "tags" output`);
140+ }
139141 }
140142
143+ assert.equal(
144+ builtImage.annotations["org.opencontainers.image.version"],
145+ refTag,
146+ `"annotations.org.opencontainers.image.version" output is not valid`
147+ );
148+
141149 - uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
142150 with :
143151 registry : ghcr.io
0 commit comments