Huy's Notes
Build Docker image with Github Action

Build Docker image with Github Action

The following action config allows you to build a docker image from your current repository, and push them to Docker's registry.

You'll need to configure your secrets first to make this run.

name: Docker Image CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/[email protected]  
      - name: Login to DockerHub
        uses: docker/[email protected] 
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Build
        id: docker_build
        uses: docker/[email protected]
        with:
          context: .
          load: true
          tags: <your-name>/<repo>:latest
      - name: Push
        run: docker push <your-name>/<repo>:latest

Referred in


If you think this note resonated, be it positive or negative, please feel free to send me an email and we can talk.