-
Notifications
You must be signed in to change notification settings - Fork 3
119 lines (107 loc) · 3.5 KB
/
publish-images.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# 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
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)