7

I'm new to Docker and trying to perform CI using GitHub Actions.

Here's my .yml file on GitHub.

name: CI to Docker Hub
on:
 push:
   branches: [main]
 pull_request:
   branches: [main]

jobs:
 build:

  runs-on: ubuntu-latest

   steps:
  - name: Check Out Repo
    uses: actions/checkout@v2

  - name: Login to Docker Hub
    uses: docker/login-action@v1
    with:
      username: ${{ secrets.DOCKER_HUB_USERNAME }}
      password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

  - name: Set up Docker Buildx
    id: buildx
    uses: docker/setup-buildx-action@v1

  - name: Build and push
    id: docker_build
    uses: docker/build-push-action@v2
    with:
      context: .
      file: ./Dockerfile
      push: true
      tags: your-order-backend:latest

  - name: Image digest
    run: echo ${{ steps.docker_build.outputs.digest }}

I have added Secrets in my Github too of Docker Hub. I'm not sure why, but it is failing at > exporting to image:

enter image description here

Sagar Bajpai
  • 361
  • 1
  • 5
  • 13
  • 1
    From the readme of build-push-action it looks like it's already using buildx by default in the newer version: "v2 of this action includes significant updates and now uses Docker Buildx". You can drop the buildx setup step and see if it helps. – ITChap Feb 26 '21 at 10:59

3 Answers3

6

It is resloved! In my case, there was no repo in the Docker Hub created whose tag I have passed here in the yml file. I created the repo and it worked

Sagar Bajpai
  • 361
  • 1
  • 5
  • 13
2

for me I fixed it by changing "push: true" to "load: true"

0

In my case, Id needed to create the repo in dockerhub as in the response of Sagar, but the problem still were there. I'd recognized I was passing the tags incorrectly, fix it and the problem was gone. (You can See the official examples)

Before:

tags: ${{ github.sha }}, latest

After (correctly):

tags: |
    henriqueholtz/fullcycle-gitops:${{ github.sha }}
    henriqueholtz/fullcycle-gitops:latest

Henrique Holtz
  • 326
  • 2
  • 6