d3vpasha
d3vpasha

Reputation: 528

I cannot publish images in Github internal docker registry with Github actions

I have created the following repository : https://github.com/d3vpasha/docker

I have a Dockerfile that is meant to create a node app:

FROM node:12 as node
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list
RUN  apt-get update && \
 apt-get install -y zip
RUN npm i -g npm@latest

I have also created the following GitHub workflow to build the image from the dockerfile & push it to the GitHub registry:

name: webapp

on:
  push:
    branches: ['main']

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}

jobs:
  build:
    name: "build webapp"
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout the repo
        uses: actions/checkout@v2

      - name: Login to Github container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push Docker image
        uses: docker/build-push-action@v1
        with:
          push: true

Once I push to the main branch, the GitHub workflow is launched & finished successfully but nothing is present in packages menu of the repo, neither in the packages menu of my own organization. Those are the final lines of the step "Build and push Docker image ":

Successfully built 98edd82e75d5
Pushing image []

I followed the official tutorial & did everything like asked but it still doesn't work.

Does someone have a clue about it?

Upvotes: 1

Views: 569

Answers (1)

atline
atline

Reputation: 31644

You miss the tags, the correct is:

- name: Build and push Docker image
  uses: docker/build-push-action@v1
  with:
    push: true
    tags: $your_dockerhub_account/$your_dockerhub_repository

BTW, docker/build-push-action is now in v2, you could consider to use it. If you use v2, it will clearly tell you next error if you not specify tags:

error: tag is needed when pushing to registry
Error: buildx failed with: error: tag is needed when pushing to registry

Upvotes: 1

Related Questions