Fix failure if image name has "/" in it's name and present in docker (#40)

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
Divyanshu Agrawal 2021-04-23 23:59:56 +05:30 committed by GitHub
parent c812c2069e
commit 5ec72be08b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View file

@ -49,7 +49,7 @@ jobs:
- name: Build image using Docker - name: Build image using Docker
run: | run: |
docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} -<<EOF docker build -t ${{ secrets.REGISTRY_USER }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} -<<EOF
FROM busybox FROM busybox
RUN echo "hello world" RUN echo "hello world"
EOF EOF
@ -58,9 +58,9 @@ jobs:
id: push id: push
uses: ./ uses: ./
with: with:
image: ${{ env.IMAGE_NAME }} image: ${{ secrets.REGISTRY_USER }}/${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }} tags: ${{ env.IMAGE_TAG }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }} registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ secrets.REGISTRY_USER }} username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.REGISTRY_PASSWORD }}

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -23,6 +23,7 @@ let podmanPath: string | undefined;
let isImageFromDocker = false; let isImageFromDocker = false;
let imageToPush: string; let imageToPush: string;
let tagsList: string[]; let tagsList: string[];
let dockerBaseUrl: string;
async function getPodmanPath(): Promise<string> { async function getPodmanPath(): Promise<string> {
if (podmanPath == null) { if (podmanPath == null) {
@ -34,7 +35,8 @@ async function getPodmanPath(): Promise<string> {
} }
// base URL that gets appended if image is pulled from the Docker imaege storage // base URL that gets appended if image is pulled from the Docker imaege storage
const dockerBaseUrl = "docker.io/library"; const DOCKER_IO = `docker.io`;
const DOCKER_IO_NAMESPACED = DOCKER_IO + `/library`;
async function run(): Promise<void> { async function run(): Promise<void> {
const DEFAULT_TAG = "latest"; const DEFAULT_TAG = "latest";
@ -43,6 +45,9 @@ async function run(): Promise<void> {
// split tags // split tags
tagsList = tags.split(" "); tagsList = tags.split(" ");
// handle the case when image name is 'namespace/imagename' and image is present in docker storage
dockerBaseUrl = imageInput.indexOf("/") > -1 ? DOCKER_IO : DOCKER_IO_NAMESPACED;
// info message if user doesn't provides any tag // info message if user doesn't provides any tag
if (tagsList.length === 0) { if (tagsList.length === 0) {
core.info(`Input "${Inputs.TAGS}" is not provided, using default tag "${DEFAULT_TAG}"`); core.info(`Input "${Inputs.TAGS}" is not provided, using default tag "${DEFAULT_TAG}"`);