Skip to content

Commit

Permalink
ci: Publish Docker images to GitHub Container Registry (#1444)
Browse files Browse the repository at this point in the history
* Publish Docker images to the GitHub Container Registry in addition to Docker Hub
   - Add corresponding ghcr.io tags
   - c.f. https://github.com/orgs/scikit-hep/packages/container/package/pyhf
  • Loading branch information
matthewfeickert authored May 10, 2021
1 parent 8db6ea8 commit bab92d0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ jobs:
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
TAGS="$TAGS,${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
# Releases also have GITHUB_REFs that are tags, so reuse VERSION
if [ "${{ github.event_name }}" = "release" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest-stable"
TAGS="$TAGS,${DOCKER_IMAGE}:latest-stable,ghcr.io/${{github.repository}}:latest-stable,ghcr.io/${{github.repository}}:${VERSION}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
Expand All @@ -55,6 +56,13 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Test build
id: docker_build_test
uses: docker/build-push-action@v2
Expand Down Expand Up @@ -99,7 +107,7 @@ jobs:
with:
context: .
file: docker/Dockerfile
tags: pyhf/pyhf:latest
tags: pyhf/pyhf:latest,ghcr.io/${{github.repository}}:latest
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
Expand Down

0 comments on commit bab92d0

Please sign in to comment.