Skip to content

Commit

Permalink
feat: publish latest dist tag only in release
Browse files Browse the repository at this point in the history
  • Loading branch information
0-vortex committed Dec 1, 2021
1 parent fb029ba commit ccb5b8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/getReleaseInfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const getReleaseInfo = (imageName, tag) => ({
name: `${imageName} container (@${tag} dist-tag)`,
const getReleaseInfo = (imageName, registry, tag) => ({
name: `${registry} container (@${tag} dist-tag)`,
url: `${imageName}`.replace(
new RegExp('^((?:ghcr|docker|quay).io)', 'gi'),
matched => ({
Expand Down
12 changes: 7 additions & 5 deletions src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const pushImage = response => {
*/
module.exports = async (pluginConfig, ctx) => {
let latestImage;
let latestTag;
let latestRegistry;

try {
const docker = new Dockerode()
Expand Down Expand Up @@ -78,15 +78,17 @@ module.exports = async (pluginConfig, ctx) => {
// @ts-ignore
await pushImage(response)

latestImage = imageName;
latestTag = tag;
if (tag === "latest") {
latestImage = imageName;
latestRegistry = registry;
}
} else {
ctx.logger.log(`Skip push docker image ${imageName}:${tag}`)
}
}

if (latestImage && latestTag) {
return getReleaseInfo(latestImage, latestTag);
if (latestImage && latestRegistry) {
return getReleaseInfo(latestImage, latestRegistry, "latest");
}
}
} catch (err) {
Expand Down

0 comments on commit ccb5b8d

Please sign in to comment.