@@ -66,16 +66,17 @@ runs:
6666 with :
6767 result-encoding : string
6868 script : |
69- // If push on default branch set tag to latest
70- const isPushOnDefaultBranch = context.eventName === 'push' && `${{ github.ref }}` === `${{ github.event.repository.default_branch }}`;
71- core.setOutput('flavor', isPushOnDefaultBranch ? 'latest=true' : 'latest=false');
72-
7369 const tagInput = `${{ inputs.tag }}`
7470 if (tagInput.length) {
7571 core.setOutput('tags',`type=semver,pattern={{raw}},value=${tagInput}`);
72+ core.setOutput('flavor', 'latest=false');
7673 return;
7774 }
7875
76+ // If push on default branch set tag to latest
77+ const isPushOnDefaultBranch = context.eventName === 'push' && `${{ github.ref }}` === `refs/heads/${{ github.event.repository.default_branch }}`;
78+ core.setOutput('flavor', isPushOnDefaultBranch ? 'latest=true' : 'latest=false');
79+
7980 const isPullRequestOrIssueComment =
8081 context.eventName === 'pull_request'
8182 || context.eventName === 'pull_request_review'
@@ -122,9 +123,21 @@ runs:
122123 core.setOutput('annotations', annotations);
123124
124125 const tags = `${{ steps.docker-metadata.outputs.tags }}`;
126+
125127 const sortedTags = tags
126128 .split("\n")
127- .sort((a, b) => b.length - a.length)
129+ .sort((a, b) => {
130+ // Move "latest" at the end
131+ if (a.includes("latest")) {
132+ return 1
133+ };
134+ if (b.includes("latest")) {
135+ return -1
136+ };
137+
138+ // Sort by length
139+ return b.length - a.length;
140+ })
128141 .join("\n");
129142
130143 core.setOutput('tags', sortedTags);
0 commit comments