This repository was archived by the owner on Aug 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (127 loc) · 5.27 KB
/
Copy pathbuild-toolboxes.yml
File metadata and controls
147 lines (127 loc) · 5.27 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Build and Push Toolboxes
on:
push:
paths:
- 'dot_toolboxes/**/Containerfile'
- '.github/workflows/build-toolboxes.yml'
workflow_dispatch:
env:
REGISTRY: quay.io
REGISTRY_USER: ${{ github.repository_owner }}
jobs:
discover-toolboxes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Discover Containerfiles
id: set-matrix
run: |
# Find all Containerfile paths and extract directory names
containerfiles=$(find dot_toolboxes -name "Containerfile" -type f | sort)
# Build JSON matrix
matrix_json="["
first=true
for containerfile in $containerfiles; do
# Extract directory name (e.g., dot_toolboxes/aws-cli/Containerfile -> aws-cli)
toolbox_name=$(dirname "$containerfile" | sed 's|dot_toolboxes/||')
if [ "$first" = true ]; then
first=false
else
matrix_json="$matrix_json,"
fi
matrix_json="$matrix_json{\"name\":\"$toolbox_name\",\"path\":\"$(dirname "$containerfile")\",\"containerfile\":\"$containerfile\"}"
done
matrix_json="$matrix_json]"
echo "Found toolboxes:"
echo "$matrix_json" | jq '.'
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
build-and-push:
needs: discover-toolboxes
if: needs.discover-toolboxes.outputs.matrix != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolbox: ${{ fromJson(needs.discover-toolboxes.outputs.matrix) }}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Container Registry
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Generate image tags
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_USER }}/${{ matrix.toolbox.name }}
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=schedule
type=semver,pattern={{major}}.{{minor}}
- name: Build with Buildah
id: build
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.REGISTRY }}/${{ env.REGISTRY_USER }}/${{ matrix.toolbox.name }}
tags: ${{ steps.meta.outputs.tags }}
containerfiles: ${{ matrix.toolbox.containerfile }}
context: ${{ matrix.toolbox.path }}
labels: |
org.opencontainers.image.title=Toolbox ${{ matrix.toolbox.name }}
org.opencontainers.image.description=Custom toolbox container for ${{ matrix.toolbox.name }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
build-args: |
BUILDTIME=${{ github.event.head_commit.timestamp }}
VERSION=${{ github.ref_name }}
- name: Push to registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Generate summary
run: |
echo "## 🐳 Built toolbox: ${{ matrix.toolbox.name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.REGISTRY }}/${{ env.REGISTRY_USER }}/${{ matrix.toolbox.name }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Path:** \`${{ matrix.toolbox.path }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.build.outputs.tags }}' | tr ' ' '\n' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
summary:
needs: [discover-toolboxes, build-and-push]
if: always()
runs-on: ubuntu-latest
container:
image: fedora:latest
steps:
- name: Generate final summary
run: |
echo "## 📦 Toolbox Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.discover-toolboxes.result }}" = "success" ] && [ "${{ needs.build-and-push.result }}" = "success" ]; then
echo "✅ All toolboxes built and pushed successfully!" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.discover-toolboxes.result }}" = "success" ] && [ "${{ needs.build-and-push.result }}" = "skipped" ]; then
echo "⏭️ No toolboxes found to build." >> $GITHUB_STEP_SUMMARY
else
echo "❌ Some builds failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Registry:** \`${{ env.REGISTRY }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Image prefix:** \`${{ env.IMAGE_PREFIX }}\`" >> $GITHUB_STEP_SUMMARY