0

Can we use github actions to call Makefile commands and build/push images to docker hub.

I saw many examples using Github actions to build and push images to dockerhub but couldnt get a sample or doc on how to integrate same with Makefile

      - name: Build and push Docker image
        uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

https://docs.github.com/en/actions/guides/publishing-docker-images

I actualy have to build some utils and copy same to Docker image. So its not just a staright forward docker build command.

ambikanair
  • 4,004
  • 11
  • 43
  • 83

1 Answers1

1

Can we use github actions to call Makefile commands and build/push images to docker hub.

YES, you can!

This answer regarding How to use Makefile in Github Actions explain how to access your Makefile commands.

Then, in your case, once you would have used the Makefile commands to manage the Docker files you want to push, you would just had to use the docker/build-push-action.

Example: You could eventually create or update a folder through the Makefile command in the workflow, and then configure the build and push step to get the files from this folder to Docker.

It would look like this for a Dockerfile.

      - run: make <command>
      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          file: ./<folder_name>/Dockerfile
          push: true
          tags: <whatever_you_want>

Just don't forget that if you want to access or execute files from the current repository in your workflow, you'll need to use the actions/checkout.

GuiFalourd
  • 15,523
  • 8
  • 44
  • 71