Skip to content

Separate publish-image workflow #12

Separate publish-image workflow

Separate publish-image workflow #12

Workflow file for this run

# SPDX-FileCopyrightText: 2023 bootloose authors
# SPDX-License-Identifier: Apache-2.0
name: Publish Images
on:
push:
branches:
- main
tags:
- 'v*'
paths:
- 'images/**/Dockerfile'
workflow_dispatch:
inputs:
tag:
description: The tag to use for images. Defaults to the tag name if publishing a tag, "latest" otherwise.
required: false
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.set-tag.outputs.tag }}
images: ${{ steps.list-images.outputs.images }}
steps:
- name: Set tag
id: set-tag
env:
TAG: "${{ inputs.tag }}"
run: |
if [ -z "$TAG" ] && [[ "$GITHUB_REF" = refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
fi
echo tag="${TAG-latest}" >>"$GITHUB_OUTPUT"
- name: List images
id: list-images
env:
BEFORE: "${{ github.event.before }}"
run: |
if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ] || [[ "$GITHUB_REF" = refs/tags/* ]]; then
gh api /repos/{owner}/{repo}/git/trees/"${GITHUB_SHA}"?recursive=1 --paginate --jq '
[ .tree[]
| select(.type == "blob")
| .path
| split("/")
| select(length == 3 and .[0] == "images" and .[2] == "Dockerfile")
| .[1]
] | unique | "images=" + tojson
' >>"$GITHUB_OUTPUT"
else
gh api /repos/{owner}/{repo}/compare/"${BEFORE}...${GITHUB_SHA}" --paginate --jq '
[ .files[].filename
| split("/")
| select(length == 3 and .[0] == "images" and .[2] == "Dockerfile")
| .[1]
] | unique | "images=" + tojson
' >>"$GITHUB_OUTPUT"
fi
publish_images:
needs: prepare
strategy:
matrix:
image: ${{fromJson(needs.prepare.outputs.images)}}
fail-fast: false
<<<<<<< HEAD

Check failure on line 69 in .github/workflows/publish-images.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-images.yaml

Invalid workflow file

You have an error in your yaml syntax on line 69
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: List image platforms
id: list-platforms
run: |
platforms=$(make -s -C images "${{ matrix.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 ${{ matrix.image }}
uses: docker/build-push-action@v5
with:
platforms: ${{ steps.list-platforms.outputs.platforms }}
push: true
tags: |
quay.io/k0sproject/bootloose-${{ matrix.image }}:${{ needs.prepare.outputs.tag }}
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)