From 20587d743fa0972b061d5e0071bb22751e2b5fbe Mon Sep 17 00:00:00 2001 From: Guillermo Mazzola Date: Mon, 15 Jul 2024 13:04:54 +0200 Subject: [PATCH] Publish to `GitHub Package Registry` and `Docker Hub` --- .github/actions/setup-host/action.yml | 25 +++++++++++++++++++++ .github/workflows/build-flavor.yaml | 32 +++++++++------------------ 2 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 .github/actions/setup-host/action.yml diff --git a/.github/actions/setup-host/action.yml b/.github/actions/setup-host/action.yml new file mode 100644 index 0000000..797b693 --- /dev/null +++ b/.github/actions/setup-host/action.yml @@ -0,0 +1,25 @@ +name: 'Setup Host' +description: 'Configures the host runner to run the build' + +runs: + using: "composite" + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + config-inline: | + [registry."docker.io"] + mirrors = ["mirror.gcr.io"] + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-flavor.yaml b/.github/workflows/build-flavor.yaml index 3ec34ed..bb104c1 100644 --- a/.github/workflows/build-flavor.yaml +++ b/.github/workflows/build-flavor.yaml @@ -35,26 +35,15 @@ jobs: outputs: digest-prefix: ${{ env.TAG_PREFIX_DIGEST }} steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up host + uses: ./.github/actions/setup-host - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - env: - GCR_IO_REGISTRY: | - [registry."docker.io"] - mirrors = ["mirror.gcr.io"] - with: - buildkitd-config-inline: ${{ inputs.only-validate && env.GCR_IO_REGISTRY || '' }} - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push by digest id: build uses: docker/build-push-action@v6 @@ -104,14 +93,16 @@ jobs: needs: build if: ${{ !inputs.only-validate }} steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up host + uses: ./.github/actions/setup-host - name: Download digests uses: actions/download-artifact@v4 with: path: /tmp/digests pattern: digests-${{ needs.build.outputs.digest-prefix }}_* merge-multiple: true - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -119,12 +110,9 @@ jobs: images: ${{ env.REGISTRY_IMAGE }} tags: | ${{ inputs.latest && 'type=raw,value=latest' || '' }} + ${{ inputs.latest && 'type=raw,value=ghcr.io/latest' || '' }} type=raw,value=${{ env.TAG_PREFIX }} - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + type=raw,value=ghcr.io/${{ env.TAG_PREFIX }} - name: Create manifest list and push working-directory: /tmp/digests run: |