Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
ci: fix "edge" tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
upsetbit committed May 12, 2022
1 parent 7d144bb commit 8bedd59
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 27 deletions.
19 changes: 11 additions & 8 deletions .github/actions/build-and-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
20 changes: 13 additions & 7 deletions .github/workflows/build-bare-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
build-bare-image:
runs-on: ubuntu-latest
env:
image-name: caian/sample-devcontainer
tag-suffix: bare

steps:
Expand All @@ -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 }}"
}
13 changes: 7 additions & 6 deletions .github/workflows/build-edge-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 11 additions & 6 deletions .github/workflows/build-full-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
}

0 comments on commit 8bedd59

Please sign in to comment.