From 6bd912fbc7526eb55ca8ed4fe6045dd20ec19885 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 23 Feb 2023 01:06:25 +0100 Subject: [PATCH] build(gha): move push multi-registries section to dedicated page Signed-off-by: CrazyMax --- _data/toc.yaml | 2 + build/ci/github-actions/examples.md | 55 ------------------ .../github-actions/push-multi-registries.md | 57 +++++++++++++++++++ 3 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 build/ci/github-actions/push-multi-registries.md diff --git a/_data/toc.yaml b/_data/toc.yaml index 2d7dfa1ff5..4b6952252b 100644 --- a/_data/toc.yaml +++ b/_data/toc.yaml @@ -1613,6 +1613,8 @@ manuals: title: Multi-platform image - path: /build/ci/github-actions/secrets/ title: Secrets + - path: /build/ci/github-actions/push-multi-registries/ + title: Push to multi-registries - path: /build/ci/github-actions/cache/ title: Cache management - path: /build/ci/github-actions/examples/ diff --git a/build/ci/github-actions/examples.md b/build/ci/github-actions/examples.md index a991500255..316a0a2f39 100644 --- a/build/ci/github-actions/examples.md +++ b/build/ci/github-actions/examples.md @@ -7,61 +7,6 @@ keywords: ci, github actions, gha, examples This page showcases different examples of how you can customize and use the Docker GitHub Actions in your CI pipelines. -## Push to multi-registries - -The following workflow will connect you to Docker Hub and [GitHub Container Registry](https://github.com/docker/login-action#github-container-registry){:target="blank" rel="noopener" class=""} -and push the image to both registries: - -{% raw %} -```yaml -name: ci - -on: - push: - branches: - - "main" - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - 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.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: | - user/app:latest - user/app:1.0.0 - ghcr.io/user/app:latest - ghcr.io/user/app:1.0.0 -``` -{% endraw %} - ## Manage tags and labels If you want an "automatic" tag management and [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md){:target="blank" rel="noopener" class=""} diff --git a/build/ci/github-actions/push-multi-registries.md b/build/ci/github-actions/push-multi-registries.md new file mode 100644 index 0000000000..6d8b0caffe --- /dev/null +++ b/build/ci/github-actions/push-multi-registries.md @@ -0,0 +1,57 @@ +--- +title: Push to multi-registries with GitHub Actions +keywords: ci, github actions, gha, buildkit, buildx, registry +--- + +The following workflow will connect you to Docker Hub and [GitHub Container Registry](https://github.com/docker/login-action#github-container-registry){:target="blank" rel="noopener" class=""} +and push the image to both registries: + +{% raw %} +```yaml +name: ci + +on: + push: + branches: + - "main" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to Docker Hub + 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.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + user/app:latest + user/app:1.0.0 + ghcr.io/user/app:latest + ghcr.io/user/app:1.0.0 +``` +{% endraw %}