Skip to content

Commit

Permalink
GitHub Action for building and publishing container images (#743)
Browse files Browse the repository at this point in the history
Images are published to dockerhub and ghcr as documented in the action file.
  • Loading branch information
BlueHatbRit committed May 10, 2023
1 parent 9fada91 commit 76ea157
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/package-and-publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
push:
branches:
- master
- docker-publish-test

jobs:
publish:
Expand All @@ -24,30 +23,39 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
statsd/statsd
ghcr.io/statsd/statsd
flavour: |
flavor: |
latest=true
# type=semver,pattern=v{{version}},event=tag
# type=semver,pattern=v{{major.minor}},event=tag
# type=semver,pattern=v{{major}},event=tag
# type=edge,branch=$repo.default_branch,event=push
# type=sha,branch=$repo.default_branch,event=push
tag: |
type=edge,event=push
type=sha,event=push
tags: |
type=semver,pattern=v{{version}},event=tag
type=semver,pattern=v{{major.minor}},event=tag
type=semver,pattern=v{{major}},event=tag
type=edge,branch=$repo.default_branch,event=push
type=sha,branch=$repo.default_branch,event=push
- name: Setup buildx
uses: docker/setup-buildx-action@v1

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

- name: Login to GitHub container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ github.token }}

- name: Build and publish image
id: docker_build
uses: docker/build-and-push-action@v3
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: Echo image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit 76ea157

Please sign in to comment.