@@ -3,52 +3,75 @@ name: Build and publish plugin container image
33on :
44 workflow_dispatch :
55 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 )'
88 required : true
99 type : string
1010 version :
1111 description : ' The plugin version (without a v prefix e.g., 0.1.0) - if not provided, will use version from package.json'
1212 required : false
1313 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'
1423
1524permissions :
1625 contents : read
1726
1827env :
1928 REGISTRY : ghcr.io
20- ORG : headlamp-k8s
21- PLUGIN : ${{ github.event.inputs.plugin }}
22- IMAGE_NAME : headlamp-plugin-${{ github.event.inputs.plugin }}
29+ ORG : ${{ github.repository_owner }}
30+ ARCHITECTURES : ${{ github.event.inputs.architectures }}
31+ NODE_VERSION : ' 20'
32+ ALPINE_VERSION : ' 3.22.0'
33+
2334jobs :
35+ setup_matrix :
36+ runs-on : ubuntu-latest
37+ outputs :
38+ matrix : ${{ steps.setup_matrix.outputs.matrix_output }}
39+ steps :
40+ - id : setup_matrix
41+ run : |
42+ echo "Setting up matrix for plugins: ${{ github.event.inputs.plugins }}"
43+ # Convert comma-separated list to JSON array
44+ PLUGINS_ARRAY=$(jq -cR 'split(",")' <<< "${{ github.event.inputs.plugins }}")
45+ echo "Matrix input: $PLUGINS_ARRAY"
46+ echo "matrix_output=$PLUGINS_ARRAY" >> $GITHUB_OUTPUT
47+
2448 build-and-publish :
49+ needs : setup_matrix
2550 runs-on : ubuntu-latest
2651 permissions :
2752 packages : write # needed for publishing the container image
53+ strategy :
54+ matrix :
55+ plugin : ${{ fromJson(needs.setup_matrix.outputs.matrix) }}
2856 steps :
2957 - name : Checkout code
30- uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
58+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.1
3159
3260 - name : Verify plugin exists
3361 run : |
34- if [ ! -d "${{ env.PLUGIN }}" ]; then
35- echo "::error::Plugin directory '${{ env.PLUGIN }}' does not exist"
62+ if [ ! -d "${{ matrix.plugin }}" ]; then
63+ echo "::error::Plugin directory '${{ matrix.plugin }}' does not exist"
3664 exit 1
3765 fi
38- echo "Plugin directory '${{ env.PLUGIN }}' verified"
39-
40- - name : Setup Node.js
41- uses : actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
42- with :
43- node-version : ' 20'
66+ echo "Plugin directory '${{ matrix.plugin }}' verified"
4467
4568 - name : Determine version
4669 id : determine_version
4770 run : |
4871 VERSION="${{ github.event.inputs.version }}"
4972 if [ -z "$VERSION" ]; then
5073 echo "Version not provided, extracting from package.json"
51- VERSION=$(node -p "require('./${{ env.PLUGIN }}/package.json').version")
74+ VERSION=$(node -p "require('./${{ matrix.plugin }}/package.json').version")
5275 echo "Extracted version: $VERSION"
5376 fi
5477 # Remove leading 'v' if present
@@ -57,37 +80,46 @@ jobs:
5780 IMAGE_TAG_VERSION="v${VERSION}"
5881 echo "VERSION=$VERSION" >> $GITHUB_ENV
5982 echo "IMAGE_TAG_VERSION=$IMAGE_TAG_VERSION" >> $GITHUB_ENV
60- echo "FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
83+ echo "FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.ORG }}/headlamp-plugin- ${{ matrix.plugin }}" >> $GITHUB_ENV
6184
6285 - name : Setup Docker Buildx
63- uses : docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
86+ uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
87+
88+ - name : Set up QEMU
89+ uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
90+ with :
91+ platforms : ${{ env.ARCHITECTURES }}
6492
6593 - name : Log in to the Container registry
66- uses : docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2 .0
94+ uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4 .0
6795 with :
6896 registry : ${{ env.REGISTRY }}
6997 username : ${{ github.actor }}
7098 password : ${{ github.token }}
7199
72100 - name : Build and push Docker image
73- uses : docker/build-push-action@0a97817b6ade9f46837855d676c4cca3a2471fc9 # v4.2.1
101+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
74102 with :
75103 context : .
76104 push : true
77105 pull : true
78- platforms : linux/amd64,linux/arm64
106+ platforms : ${{ env.ARCHITECTURES }}
79107 tags : ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG_VERSION }},${{ env.FULL_IMAGE_NAME }}:latest
80108 labels : |
81109 org.opencontainers.image.source=${{ github.event.repository.html_url }}
82110 org.opencontainers.image.licenses=Apache-2.0
111+ build-args : |
112+ PLUGIN=${{ matrix.plugin }}
113+ BASE_IMAGE_VERSION=${{ env.NODE_VERSION }}
114+ FINAL_IMAGE_VERSION=${{ env.ALPINE_VERSION }}
83115 provenance : true
84- build-args : PLUGIN=${{ env.PLUGIN }}
85116 cache-from : type=gha
86117 cache-to : type=gha,mode=max
87118
88119 - name : Summary
89120 run : |
90121 echo "## Container Image Published" >> $GITHUB_STEP_SUMMARY
91- echo "Plugin: ${{ env.PLUGIN }}" >> $GITHUB_STEP_SUMMARY
122+ echo "Plugin: ${{ matrix.plugin }}" >> $GITHUB_STEP_SUMMARY
92123 echo "Version: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY
93124 echo "Image: ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG_VERSION }}" >> $GITHUB_STEP_SUMMARY
125+ echo "Architectures: ${{ env.ARCHITECTURES }}" >> $GITHUB_STEP_SUMMARY
0 commit comments