@@ -3,49 +3,72 @@ name: Build and publish plugin container image
3
3
on :
4
4
workflow_dispatch :
5
5
inputs :
6
- plugin :
7
- description : ' The plugin name (e.g., flux)'
6
+ plugins :
7
+ description : ' Comma-separated list of plugin names to build (e.g., flux,cert-manager )'
8
8
required : true
9
9
type : string
10
10
version :
11
11
description : ' The plugin version (without a v prefix e.g., 0.1.0) - if not provided, will use version from package.json'
12
12
required : false
13
13
type : string
14
+ architectures :
15
+ description : ' Target architectures to build for'
16
+ required : true
17
+ type : choice
18
+ options :
19
+ - linux/amd64,linux/arm64
20
+ - linux/amd64
21
+ - linux/arm64
22
+ default : ' linux/amd64,linux/arm64'
14
23
15
24
env :
16
25
REGISTRY : ghcr.io
17
- ORG : headlamp-k8s
18
- PLUGIN : ${{ github.event.inputs.plugin }}
19
- IMAGE_NAME : headlamp-plugin-${{ github.event.inputs.plugin }}
26
+ ORG : ${{ github.repository_owner }}
27
+ ARCHITECTURES : ${{ github.event.inputs.architectures }}
28
+ NODE_VERSION : ' 20'
29
+ ALPINE_VERSION : ' 3.22.0'
30
+
20
31
jobs :
32
+ setup_matrix :
33
+ runs-on : ubuntu-latest
34
+ outputs :
35
+ matrix : ${{ steps.setup_matrix.outputs.matrix_output }}
36
+ steps :
37
+ - id : setup_matrix
38
+ run : |
39
+ echo "Setting up matrix for plugins: ${{ github.event.inputs.plugins }}"
40
+ # Convert comma-separated list to JSON array
41
+ PLUGINS_ARRAY=$(jq -cR 'split(",")' <<< "${{ github.event.inputs.plugins }}")
42
+ echo "Matrix input: $PLUGINS_ARRAY"
43
+ echo "matrix_output=$PLUGINS_ARRAY" >> $GITHUB_OUTPUT
44
+
21
45
build-and-publish :
46
+ needs : setup_matrix
22
47
runs-on : ubuntu-latest
23
48
permissions :
24
49
packages : write # needed for publishing the container image
50
+ strategy :
51
+ matrix :
52
+ plugin : ${{ fromJson(needs.setup_matrix.outputs.matrix) }}
25
53
steps :
26
54
- name : Checkout code
27
- uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
55
+ uses : actions/checkout@v4
28
56
29
57
- name : Verify plugin exists
30
58
run : |
31
- if [ ! -d "${{ env.PLUGIN }}" ]; then
32
- echo "::error::Plugin directory '${{ env.PLUGIN }}' does not exist"
59
+ if [ ! -d "${{ matrix.plugin }}" ]; then
60
+ echo "::error::Plugin directory '${{ matrix.plugin }}' does not exist"
33
61
exit 1
34
62
fi
35
- echo "Plugin directory '${{ env.PLUGIN }}' verified"
36
-
37
- - name : Setup Node.js
38
- uses : actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
39
- with :
40
- node-version : ' 20'
63
+ echo "Plugin directory '${{ matrix.plugin }}' verified"
41
64
42
65
- name : Determine version
43
66
id : determine_version
44
67
run : |
45
68
VERSION="${{ github.event.inputs.version }}"
46
69
if [ -z "$VERSION" ]; then
47
70
echo "Version not provided, extracting from package.json"
48
- VERSION=$(node -p "require('./${{ env.PLUGIN }}/package.json').version")
71
+ VERSION=$(node -p "require('./${{ matrix.plugin }}/package.json').version")
49
72
echo "Extracted version: $VERSION"
50
73
fi
51
74
# Remove leading 'v' if present
@@ -54,37 +77,46 @@ jobs:
54
77
IMAGE_TAG_VERSION="v${VERSION}"
55
78
echo "VERSION=$VERSION" >> $GITHUB_ENV
56
79
echo "IMAGE_TAG_VERSION=$IMAGE_TAG_VERSION" >> $GITHUB_ENV
57
- echo "FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
80
+ echo "FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.ORG }}/headlamp-plugin- ${{ matrix.plugin }}" >> $GITHUB_ENV
58
81
59
82
- name : Setup Docker Buildx
60
- uses : docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
83
+ uses : docker/setup-buildx-action@v3
84
+
85
+ - name : Set up QEMU
86
+ uses : docker/setup-qemu-action@v3
87
+ with :
88
+ platforms : ${{ env.ARCHITECTURES }}
61
89
62
90
- name : Log in to the Container registry
63
- uses : docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
91
+ uses : docker/login-action@v3
64
92
with :
65
93
registry : ${{ env.REGISTRY }}
66
94
username : ${{ github.actor }}
67
95
password : ${{ github.token }}
68
96
69
97
- name : Build and push Docker image
70
- uses : docker/build-push-action@0a97817b6ade9f46837855d676c4cca3a2471fc9 # v4.2.1
98
+ uses : docker/build-push-action@v6
71
99
with :
72
100
context : .
73
101
push : true
74
102
pull : true
75
- platforms : linux/amd64,linux/arm64
103
+ platforms : ${{ env.ARCHITECTURES }}
76
104
tags : ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG_VERSION }},${{ env.FULL_IMAGE_NAME }}:latest
77
105
labels : |
78
106
org.opencontainers.image.source=${{ github.event.repository.html_url }}
79
107
org.opencontainers.image.licenses=Apache-2.0
108
+ build-args : |
109
+ PLUGIN=${{ matrix.plugin }}
110
+ BASE_IMAGE_VERSION=${{ env.NODE_VERSION }}
111
+ FINAL_IMAGE_VERSION=${{ env.ALPINE_VERSION }}
80
112
provenance : true
81
- build-args : PLUGIN=${{ env.PLUGIN }}
82
113
cache-from : type=gha
83
114
cache-to : type=gha,mode=max
84
115
85
116
- name : Summary
86
117
run : |
87
118
echo "## Container Image Published" >> $GITHUB_STEP_SUMMARY
88
- echo "Plugin: ${{ env.PLUGIN }}" >> $GITHUB_STEP_SUMMARY
119
+ echo "Plugin: ${{ matrix.plugin }}" >> $GITHUB_STEP_SUMMARY
89
120
echo "Version: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY
90
121
echo "Image: ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG_VERSION }}" >> $GITHUB_STEP_SUMMARY
122
+ echo "Architectures: ${{ env.ARCHITECTURES }}" >> $GITHUB_STEP_SUMMARY
0 commit comments