Skip to content

Commit

Permalink
Separate publish-image workflow
Browse files Browse the repository at this point in the history
Factor out the matrix build in its own workflow. Allow for the workflow
to be triggered manually. This allows individual images to be published
manually.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Feb 9, 2024
1 parent 781d1c2 commit d5f7fb3
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 2 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/publish-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# SPDX-FileCopyrightText: 2023 bootloose authors
# SPDX-License-Identifier: Apache-2.0

name: Publish Image

on:
workflow_call:
inputs:
image:
type: string
description: The image to be published.
tag:
type: string
description: The tag to use for the image. Defaults to :latest if not specified.
required: false
default: latest
secrets:
QUAY_USERNAME:
description: The username used to log in to Quay.io.
required: true
QUAY_PASSWORD:
description: The password used to log in to Quay.io.
required: true

workflow_dispatch:
inputs:
image:
type: string
description: The image to be published.
tag:
type: string
description: The tag to use for the image. Defaults to :latest if not specified.
required: false
default: latest

jobs:
publish_image:
needs: prepare
runs-on: ubuntu-20.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: List image platforms
id: list-platforms
run: |
platforms=$(make -s -C images "${{ inputs.image }}-platforms")
echo "platforms=${platforms}" >> $GITHUB_OUTPUT
- name: Login to Quay
uses: docker/login-action@v3
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ steps.list-platforms.outputs.platforms }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Buildx Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx

- name: Build ${{ inputs.image }}
uses: docker/build-push-action@v5
with:
platforms: ${{ steps.list-platforms.outputs.platforms }}
push: true
tags: |
quay.io/k0sproject/bootloose-${{ inputs.image }}:${{ inputs.tag }}
context: images/${{ inputs.image }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
16 changes: 14 additions & 2 deletions .github/workflows/publish-images.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2023 bootloose authors
# SPDX-License-Identifier: Apache-2.0

name: Publish Images

on:
Expand Down Expand Up @@ -58,12 +61,12 @@ jobs:
publish_images:
needs: prepare
runs-on: ubuntu-20.04
strategy:
matrix:
matrix:
image: ${{fromJson(needs.prepare.outputs.images)}}
fail-fast: false

<<<<<<< HEAD
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -105,3 +108,12 @@ jobs:
context: images/${{ matrix.image }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
=======
uses: ./.github/workflows/publish-image.yaml
with:
image: ${{ matrix.image }}
tag: ${{ needs.prepare.outputs.tag }}
secrets:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
>>>>>>> 33c2fa2 (Separate publish-image workflow)

0 comments on commit d5f7fb3

Please sign in to comment.