@@ -3,49 +3,72 @@ 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
1524env :
1625  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+ 
2031jobs :
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+            
2145   build-and-publish :
46+     needs : setup_matrix 
2247    runs-on : ubuntu-latest 
2348    permissions :
2449      packages : write  #  needed for publishing the container image
50+     strategy :
51+       matrix :
52+         plugin : ${{ fromJson(needs.setup_matrix.outputs.matrix) }} 
2553    steps :
2654      - name : Checkout code 
27-         uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332   #  4.1.7 
55+         uses : actions/checkout@v4  
2856
2957      - name : Verify plugin exists 
3058        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" 
3361            exit 1 
3462          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" 
4164
4265       - name : Determine version 
4366        id : determine_version 
4467        run : | 
4568          VERSION="${{ github.event.inputs.version }}" 
4669          if [ -z "$VERSION" ]; then 
4770            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") 
4972            echo "Extracted version: $VERSION" 
5073          fi 
5174          # Remove leading 'v' if present 
@@ -54,37 +77,46 @@ jobs:
5477          IMAGE_TAG_VERSION="v${VERSION}" 
5578          echo "VERSION=$VERSION" >> $GITHUB_ENV 
5679          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 
5881
5982       - 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 }} 
6189
6290      - name : Log in to the Container registry 
63-         uses : docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc   #  v2.2.0 
91+         uses : docker/login-action@v3  
6492        with :
6593          registry : ${{ env.REGISTRY }} 
6694          username : ${{ github.actor }} 
6795          password : ${{ github.token }} 
6896
6997      - name : Build and push Docker image 
70-         uses : docker/build-push-action@0a97817b6ade9f46837855d676c4cca3a2471fc9   #  v4.2.1 
98+         uses : docker/build-push-action@v6  
7199        with :
72100          context : . 
73101          push : true 
74102          pull : true 
75-           platforms : linux/amd64,linux/arm64 
103+           platforms : ${{ env.ARCHITECTURES }} 
76104          tags : ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG_VERSION }},${{ env.FULL_IMAGE_NAME }}:latest 
77105          labels : | 
78106            org.opencontainers.image.source=${{ github.event.repository.html_url }} 
79107            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 }} 
80112           provenance : true 
81-           build-args : PLUGIN=${{ env.PLUGIN }} 
82113          cache-from : type=gha 
83114          cache-to : type=gha,mode=max 
84115
85116      - name : Summary 
86117        run : | 
87118          echo "## Container Image Published" >> $GITHUB_STEP_SUMMARY 
88-           echo "Plugin: ${{ env.PLUGIN  }}" >> $GITHUB_STEP_SUMMARY 
119+           echo "Plugin: ${{ matrix.plugin  }}" >> $GITHUB_STEP_SUMMARY 
89120          echo "Version: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY 
90121          echo "Image: ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG_VERSION }}" >> $GITHUB_STEP_SUMMARY 
122+           echo "Architectures: ${{ env.ARCHITECTURES }}" >> $GITHUB_STEP_SUMMARY 
0 commit comments