Build and push latest Docker image

The following is a quick recipe to build and push a latest Docker image.


name: docker-latest
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: azure/docker-login@v1
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
    - run: |
        docker build -f Dockerfile -t myusername/myimagename .
        docker push myusername/myimagename
        

Add the DOCKER_USERNAME and DOCKER_PASSWORD as secrets to your GitHub account. Adjust the image name in both the build and the push command.

Posted July 1st, 2021

Up