5

Quick Tip: GitHub Action for pushing docker images

 3 years ago
source link: https://sj14.gitlab.io/post/2020/06-16-github-action-registry/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Quick Tip: GitHub Action for pushing docker images

2020-06-16

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK