about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-16 18:46:11 +0100
committerGitHub <noreply@github.com>2025-01-16 18:46:11 +0100
commit701f1922ef58e33514dd44f654699d6ffdd6f4b3 (patch)
tree41f66538df598110d3749ab98eead28f6694ec37
parentf7e1ae40f56c7bbb3726edf3adafe3db9558c908 (diff)
parentf5fe0a029389f25056c916ba6fafc18518f708f6 (diff)
downloadrust-701f1922ef58e33514dd44f654699d6ffdd6f4b3.tar.gz
rust-701f1922ef58e33514dd44f654699d6ffdd6f4b3.zip
Rollup merge of #135574 - marcoieni:docker-ghcr-mirror, r=Kobzol
ci: mirror ubuntu:22.04 to ghcr.io
-rw-r--r--.github/workflows/ghcr.yml57
1 files changed, 57 insertions, 0 deletions
diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml
new file mode 100644
index 00000000000..0fcd1b17816
--- /dev/null
+++ b/.github/workflows/ghcr.yml
@@ -0,0 +1,57 @@
+# Mirror DockerHub images used by the Rust project to ghcr.io.
+# Images are available at https://github.com/orgs/rust-lang/packages.
+#
+# In some CI jobs, we pull images from ghcr.io instead of Docker Hub because
+# Docker Hub has a rate limit, while ghcr.io doesn't.
+# Those images are pushed to ghcr.io by this job.
+#
+# Note that authenticating to DockerHub or other registries isn't possible
+# for PR jobs, because forks can't access secrets.
+# That's why we use ghcr.io: it has no rate limit and it doesn't require authentication.
+
+name: GHCR
+
+on:
+  workflow_dispatch:
+  schedule:
+    # Run daily at midnight UTC
+    - cron: '0 0 * * *'
+
+jobs:
+  mirror:
+    name: DockerHub mirror
+    runs-on: ubuntu-24.04
+    if: github.repository == 'rust-lang/rust'
+    permissions:
+      # Needed to write to the ghcr.io registry
+      packages: write
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          persist-credentials: false
+
+      - name: Log in to registry
+        run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
+
+      # Download crane in the current directory.
+      # We use crane because it copies the docker image for all the architectures available in
+      # DockerHub for the image.
+      # Learn more about crane at
+      # https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md
+      - name: Download crane
+        run: |
+          curl -sL "https://github.com/google/go-containerregistry/releases/download/${VERSION}/go-containerregistry_${OS}_${ARCH}.tar.gz" | tar -xzf -
+        env:
+          VERSION: v0.20.2
+          OS: Linux
+          ARCH: x86_64
+
+      - name: Mirror DockerHub
+        run: |
+          # DockerHub image we want to mirror
+          image="ubuntu:22.04"
+
+          # Mirror image from DockerHub to ghcr.io
+          ./crane copy \
+            docker.io/${image} \
+            ghcr.io/${{ github.repository_owner }}/${image}