Skip to content
anchor

GitHub Action

Build and Push Docker Image to Docker Hub

v3.0.2 Latest version

Build and Push Docker Image to Docker Hub

anchor

Build and Push Docker Image to Docker Hub

This will push package.json to docker registry as docker image

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Build and Push Docker Image to Docker Hub

uses: FireWork-Production-Private-Ltd/[email protected]

Learn more about this action in FireWork-Production-Private-Ltd/docker-repos

Choose a version

Docker-Repos

  • this will have config and express package under its docker image.

workflow

name: Build and Push Docker Image to Docker Hub

on: push
jobs:
  push_to_registry:
    name: push docker image to hub
    runs-on: ubuntu-latest
    steps:
      - name: check repository
        uses: actions/checkout@v4

      - name: login to docker registry
        uses: docker/login-action@v3
        with:
          username: ${{secrets.DOCKERHUB_USERNAME}}
          password: ${{secrets.DOCKERHUB_TOKEN}}

      - name: build and push docker image to registry
        uses: docker/build-push-action@v5
        with:
          context: DockerFileFolder/
          push: true
          tags: black1512/demo1:latest
  • you need to specify your DOCKERHUB_USERNAME and DOCKERHUB_TOKEN inside your repos secrets.

Docker Registry

  • This will update https://hub.docker.com/r/black1512/demo1 docker registry.
# pull this image by
docker pull black1512/demo1:latest
  • need to configure DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets for your repo.