Home · RSS · E-Mail · GitHub · GitLab · Twitter

Quick Tip: GitHub Action for pushing docker images

Here is a full example of using the official Docker build-push-action for GitHub to publish directly to the registry of this repo. Just create a .github/workflows/docker.yaml file in your repo with the following content:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
name: Publish Docker
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Publish to Registry
      uses: docker/build-push-action@v1
      with:
        username: ${{ github.actor }}
        password: ${{ github.token }}
        registry: docker.pkg.github.com
        repository: ${{ github.repository }}/image
        tag_with_ref: true
        tag_with_sha: true
        add_git_labels: true

Of course, you need a valid Dockerfile in your repo. Otherwise, there is no need to add anyting else, all ${{ github.X }} variables are already set.


Home · RSS · E-Mail · GitHub · GitLab · Twitter