Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Docker images to multiple container registries #1443

Closed
matthewfeickert opened this issue May 10, 2021 · 2 comments · Fixed by #1444
Closed

Publish Docker images to multiple container registries #1443

matthewfeickert opened this issue May 10, 2021 · 2 comments · Fixed by #1444
Assignees
Labels
CI CI systems, GitHub Actions Docker Involving Docker images or builds

Comments

@matthewfeickert
Copy link
Member

matthewfeickert commented May 10, 2021

Description

Now that PR #1441 and PR #1442 are in, we can easily publish Docker images to multiple image/container registries using the docker/login-action@v1 GitHub Action. docker/login-action@v1 currently supports the following registries:

  • Docker Hub
  • GitHub Packages Docker Registry
  • GitHub Container Registry
  • GitLab
  • Azure Container Registry (ACR)
  • Google Container Registry (GCR)
  • Google Artifact Registry (GAR)
  • AWS Elastic Container Registry (ECR)
  • AWS Public Elastic Container Registry (ECR)
  • OCI Oracle Cloud Infrastructure Registry (OCIR)
  • Quay.io

The relevant diff for .github/workflows/docker.yml to publish to the GitHub Container Registry would be something like (c.f. branch ci/add-github-container-registry)

@@ -37,7 +37,7 @@ jobs:
           TAGS="${DOCKER_IMAGE}:${VERSION}"
           TAGS="$TAGS,${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
           if [ "${{ github.event_name }}" = "release" ]; then
-            TAGS="$TAGS,${DOCKER_IMAGE}:latest-stable"
+            TAGS="$TAGS,${DOCKER_IMAGE}:latest-stable,ghcr.io/${{github.repository}}:latest-stable"
           fi
           echo ::set-output name=version::${VERSION}
           echo ::set-output name=tags::${TAGS}
@@ -55,6 +55,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
@@ -99,7 +106,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 }}
@matthewfeickert matthewfeickert added CI CI systems, GitHub Actions Docker Involving Docker images or builds labels May 10, 2021
@matthewfeickert matthewfeickert self-assigned this May 10, 2021
@matthewfeickert
Copy link
Member Author

@lukasheinrich @kratsg any thoughts or concerns on this?

@lukasheinrich
Copy link
Contributor

no this looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI CI systems, GitHub Actions Docker Involving Docker images or builds
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants