mirror of
https://github.com/docker/build-push-action.git
synced 2025-04-19 18:06:46 +00:00
Parse image reference before push
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
b15ad02902
commit
320acb8414
3 changed files with 84 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
import * as os from 'os';
|
||||
import * as buildx from './buildx';
|
||||
import {Inputs, loadInputs, mustBuildx} from './context-helper';
|
||||
import {Image, parseImage} from './docker';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
|
@ -84,10 +85,14 @@ async function run(): Promise<void> {
|
|||
if (!buildxEnabled && inputs.push) {
|
||||
let pushRepos: Array<string> = [];
|
||||
await asyncForEach(inputs.tags, async tag => {
|
||||
const repo = tag.split(':', -1)[0];
|
||||
const img: Image | undefined = await parseImage(tag);
|
||||
if (!img) {
|
||||
core.warning(`Cannot parse image reference ${tag}`);
|
||||
return;
|
||||
}
|
||||
const repo: string = `${img.registry}${img.namespace}${img.repository}`;
|
||||
if (!pushRepos.includes(repo)) {
|
||||
pushRepos.push(repo);
|
||||
|
||||
core.info(`⬆️ Pushing ${repo}...`);
|
||||
await exec.exec('docker', ['push', repo]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue