1+ #
2+ # Copyright (C) 2025 Red Hat, Inc.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ #
16+ # SPDX-License-Identifier: Apache-2.0
17+
18+ name : build and publish next image
19+
20+ permissions :
21+ contents : read
22+ packages : write
23+ attestations : write
24+ id-token : write
25+
26+ on :
27+ workflow_dispatch :
28+ push :
29+ branches :
30+ - main
31+
32+ jobs :
33+ check-builder-changes :
34+ runs-on : ubuntu-24.04
35+ outputs :
36+ builder_required : ${{ steps.check.outputs.builder_required }}
37+ steps :
38+ - name : Checkout Repository
39+ uses : actions/checkout@v4
40+ with :
41+ fetch-depth : 2 # Ensure we have at least one previous commit for diff check
42+
43+ - name : Check for builder-related changes
44+ id : check
45+ run : |
46+ if git diff --name-only HEAD^ HEAD | grep -E '^(package.json|pnpm-lock.yaml|build/Containerfile.builder|.github/workflows/next-build.yaml)$'; then
47+ echo "builder_required=true" >> $GITHUB_OUTPUT
48+ else
49+ echo "builder_required=false" >> $GITHUB_OUTPUT
50+ fi
51+
52+ builder-image :
53+ needs : check-builder-changes
54+ if : needs.check-builder-changes.outputs.builder_required == 'true'
55+ name : Build and publish builder OCI images only if pnpm-lock.yaml or package.json changes
56+ runs-on : ubuntu-24.04
57+
58+ steps :
59+ - uses : actions/checkout@v4
60+ with :
61+ fetch-depth : 0
62+
63+ - name : Install qemu dependency
64+ run : |
65+ sudo apt-get update
66+ sudo apt-get install -y qemu-user-static
67+
68+ - name : build builder image
69+ id : builder-image
70+ uses : redhat-actions/buildah-build@v2
71+ with :
72+ image : podman-desktop-extension-kubernetes-dashboard-builder
73+ tags : next ${{ github.sha }}
74+ platforms : linux/amd64, linux/arm64
75+ containerfiles : |
76+ build/Containerfile.builder
77+ context : .
78+ oci : true
79+
80+ - name : Log in to ghcr.io
81+ uses : redhat-actions/podman-login@v1
82+ with :
83+ username : ${{ github.actor }}
84+ password : ${{ secrets.GITHUB_TOKEN }}
85+ registry : ghcr.io
86+
87+ - name : publish builder to ghcr.io
88+ id : push-to-ghcr
89+ uses : redhat-actions/push-to-registry@v2
90+ with :
91+ image : ${{ steps.builder-image.outputs.image }}
92+ tags : ${{ steps.builder-image.outputs.tags }}
93+ registry : ghcr.io/${{ github.repository_owner }}
94+
95+ - name : Generate artifact attestation
96+ uses : actions/attest-build-provenance@v2
97+ with :
98+ subject-name : ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-kubernetes-dashboard-builder
99+ subject-digest : ${{ steps.push-to-ghcr.outputs.digest }}
100+ push-to-registry : true
101+
102+
103+ extension-image :
104+ name : Build and publish extension OCI image
105+ if : always()
106+ runs-on : ubuntu-24.04
107+ needs : builder-image
108+
109+ steps :
110+ - uses : actions/checkout@v4
111+ with :
112+ fetch-depth : 0
113+
114+ - name : Install qemu dependency
115+ run : |
116+ sudo apt-get update
117+ sudo apt-get install -y qemu-user-static
118+
119+ - name : build extension image
120+ id : extension-image
121+ uses : redhat-actions/buildah-build@v2
122+ with :
123+ image : podman-desktop-extension-kubernetes-dashboard
124+ tags : next ${{ github.sha }}
125+ archs : amd64, arm64
126+ containerfiles : |
127+ build/Containerfile
128+ context : .
129+ oci : true
130+
131+ - name : Log in to ghcr.io
132+ uses : redhat-actions/podman-login@v1
133+ with :
134+ username : ${{ github.actor }}
135+ password : ${{ secrets.GITHUB_TOKEN }}
136+ registry : ghcr.io
137+
138+ - name : publish extension to ghcr.io
139+ id : push-to-ghcr
140+ uses : redhat-actions/push-to-registry@v2
141+ with :
142+ image : ${{ steps.extension-image.outputs.image }}
143+ tags : ${{ steps.extension-image.outputs.tags }}
144+ registry : ghcr.io/${{ github.repository_owner }}
145+
146+ - name : Generate artifact attestation
147+ uses : actions/attest-build-provenance@v2
148+ with :
149+ subject-name : ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-kubernetes-dashboard
150+ subject-digest : ${{ steps.push-to-ghcr.outputs.digest }}
151+ push-to-registry : true
0 commit comments