From 8bedd590658e3c0c4a12bdf29ddc24f3a583fe46 Mon Sep 17 00:00:00 2001 From: Caian Ertl Date: Thu, 12 May 2022 00:05:56 -0300 Subject: [PATCH] ci: fix "edge" tagging --- .github/actions/build-and-push/action.yml | 19 +++++++++++-------- .github/workflows/build-bare-image.yml | 20 +++++++++++++------- .github/workflows/build-edge-image.yml | 13 +++++++------ .github/workflows/build-full-image.yml | 17 +++++++++++------ 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/.github/actions/build-and-push/action.yml b/.github/actions/build-and-push/action.yml index d8044f4..abcba45 100644 --- a/.github/actions/build-and-push/action.yml +++ b/.github/actions/build-and-push/action.yml @@ -8,7 +8,11 @@ inputs: image-name: required: true - description: The Docker image name (user/repo:tag) + description: The Docker image name (user/repo) + + tagged-name: + required: true + description: The tagged Docker image name (user/repo:tag) tag-suffix: required: true @@ -45,18 +49,17 @@ runs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: | - build-image-${{ inputs.tag-suffix }}-buildx-${{ github.sha }} - build-image-${{ inputs.tag-suffix }}-buildx- - restore-keys: | - build-image-${{ inputs.tag-suffix }}-buildx- + key: ${{ env.cache-key }} + restore-keys: ${{ env.cache-key }} + env: + cache-key: build-image-${{ inputs.tag-suffix }}-buildx - name: Build and push "${{ inputs.tag-suffix }}" image uses: docker/build-push-action@v2 with: context: ${{ inputs.path }} push: true - tags: ${{ inputs.image-name }}-${{ inputs.tag-suffix }} + tags: ${{ inputs.tagged-name }}-${{ inputs.tag-suffix }} builder: ${{ steps.buildx.outputs.name }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache @@ -67,7 +70,7 @@ runs: with: context: ${{ inputs.path }} push: true - tags: ${{ inputs.image-name }}-${{ inputs.tag-suffix }} + tags: ${{ inputs.image-name }}:latest builder: ${{ steps.buildx.outputs.name }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/.github/workflows/build-bare-image.yml b/.github/workflows/build-bare-image.yml index ced0806..d9287c0 100644 --- a/.github/workflows/build-bare-image.yml +++ b/.github/workflows/build-bare-image.yml @@ -11,6 +11,7 @@ jobs: build-bare-image: runs-on: ubuntu-latest env: + image-name: caian/sample-devcontainer tag-suffix: bare steps: @@ -21,21 +22,26 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: caian/sample-devcontainer + images: ${{ env.image-name }} tags: type=semver,pattern={{version}} flavor: latest=false - - name: Build and push + - name: Build and push "${{ env.tag-suffix }}" image uses: ./.github/actions/build-and-push with: - path: images/${{ env.tag-suffix }} - image-name: ${{ steps.meta.outputs.tags }} - tag-suffix: ${{ env.tag-suffix }} - dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + path: "images/${{ env.tag-suffix }}" + tag-suffix: "${{ env.tag-suffix }}" + image-name: "${{ env.image-name }}" + tagged-name: "${{ steps.meta.outputs.tags }}" + dockerhub-token: "${{ secrets.DOCKERHUB_TOKEN }}" - name: Trigger "full" image build uses: peter-evans/repository-dispatch@v2 with: token: ${{ secrets.GH_AUTH_TOKEN }} event-type: build-full-image - client-payload: '{"tag": "${{ steps.meta.outputs.tags }}"}' + client-payload: > + { + "image_name": "${{ env.image-name }}", + "tagged_name": "${{ steps.meta.outputs.tags }}" + } diff --git a/.github/workflows/build-edge-image.yml b/.github/workflows/build-edge-image.yml index 19b1c52..8a577b6 100644 --- a/.github/workflows/build-edge-image.yml +++ b/.github/workflows/build-edge-image.yml @@ -27,11 +27,12 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Build and push + - name: Build and push "${{ env.tag-suffix }}" image uses: ./.github/actions/build-and-push with: - path: images/${{ env.tag-suffix }} - image-name: caian/sample-devcontainer - tag-suffix: ${{ env.tag-suffix }} - push-latest: 'yes' - dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + path: "images/${{ env.tag-suffix }}" + tag-suffix: "${{ env.tag-suffix }}" + image-name: "${{ github.event.client_payload.image_name }}" + tagged-name: "${{ github.event.client_payload.tagged_name }}" + dockerhub-token: "${{ secrets.DOCKERHUB_TOKEN }}" + push-latest: "yes" diff --git a/.github/workflows/build-full-image.yml b/.github/workflows/build-full-image.yml index 5661e16..3ae7f14 100644 --- a/.github/workflows/build-full-image.yml +++ b/.github/workflows/build-full-image.yml @@ -16,17 +16,22 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Build and push + - name: Build and push "${{ env.tag-suffix }}" image uses: ./.github/actions/build-and-push with: - path: images/${{ env.tag-suffix }} - image-name: ${{ github.event.client_payload.tag }} - tag-suffix: ${{ env.tag-suffix }} - dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + path: "images/${{ env.tag-suffix }}" + tag-suffix: "${{ env.tag-suffix }}" + image-name: "${{ github.event.client_payload.image_name }}" + tagged-name: "${{ github.event.client_payload.tagged_name }}" + dockerhub-token: "${{ secrets.DOCKERHUB_TOKEN }}" - name: Trigger "edge" image build uses: peter-evans/repository-dispatch@v2 with: token: ${{ secrets.GH_AUTH_TOKEN }} event-type: build-edge-image - client-payload: '{"tag": "${{ steps.meta.outputs.tags }}"}' + client-payload: > + { + "image_name": "${{ github.event.client_payload.image_name }}", + "tagged_name": "${{ github.event.client_payload.tagged_name }}" + }