12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- name : Next
15
+ name : Build Next Image
16
16
17
17
on :
18
18
push :
@@ -25,11 +25,18 @@ concurrency:
25
25
26
26
env :
27
27
REGISTRY : quay.io
28
+ REGISTRY_IMAGE : rhdh-community/rhdh
28
29
29
30
jobs :
30
31
build-image :
31
32
name : Build Image
32
33
runs-on : ubuntu-latest
34
+ strategy :
35
+ fail-fast : false
36
+ matrix :
37
+ platform :
38
+ - linux/amd64
39
+ - linux/arm64
33
40
permissions :
34
41
contents : read
35
42
packages : write
@@ -40,26 +47,91 @@ jobs:
40
47
with :
41
48
fetch-depth : 0
42
49
43
- - name : Get the last commit short SHA
50
+ - name : Prepare
44
51
run : |
45
- SHORT_SHA=$(git rev-parse --short=8 HEAD)
46
- echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
47
- if [[ -f packages/app/src/build-metadata.json ]]; then
48
- repo="${{ github.repository }}"
49
- now="$(date -u +%FT%TZ)"
50
- sed -i packages/app/src/build-metadata.json -r \
51
- -e 's|("Last Commit:.+)|"Last Commit: '$repo' @ '$SHORT_SHA'"|'
52
- fi
52
+ platform=${{ matrix.platform }}
53
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
54
+ echo "PLATFORM_ARCH=${platform#*/}" >> $GITHUB_ENV
55
+
56
+ - name : Get the last commit short SHA
57
+ uses : ./.github/actions/get-sha
58
+
53
59
54
60
- name : Build and Push with Buildx
55
61
uses : ./.github/actions/docker-build
62
+ id : build
56
63
with :
57
64
registry : ${{ env.REGISTRY }}
58
65
username : ${{ secrets.QUAY_USERNAME }}
59
66
password : ${{ secrets.QUAY_TOKEN }}
60
- imageName : rhdh-community/rhdh
67
+ imageName : ${{ env.REGISTRY_IMAGE }}
61
68
imageTags : |
62
- type=raw,value=next
63
- type=sha,prefix=next-
69
+ type=raw,value=next-${{ env.PLATFORM_ARCH }}
70
+ type=sha,prefix=next-,suffix=-${{ env.PLATFORM_ARCH }}
64
71
imageLabels : quay.expires-after=14d
65
72
push : true
73
+ platform : ${{ matrix.platform }}
74
+
75
+ - name : Export digest
76
+ run : |
77
+ mkdir -p /tmp/digests
78
+ digest="${{ steps.build.outputs.digest }}"
79
+ touch "/tmp/digests/${digest#sha256:}"
80
+
81
+ - name : Upload digest
82
+ uses : actions/upload-artifact@v4
83
+ with :
84
+ name : digests-${{ env.PLATFORM_PAIR }}
85
+ path : /tmp/digests/*
86
+ if-no-files-found : error
87
+ retention-days : 1
88
+
89
+
90
+ merge :
91
+ runs-on : ubuntu-latest
92
+ needs :
93
+ - build-image
94
+ steps :
95
+ - name : Checkout
96
+ uses : actions/checkout@v4
97
+ with :
98
+ fetch-depth : 0
99
+
100
+ - name : Download digests
101
+ uses : actions/download-artifact@v4
102
+ with :
103
+ path : /tmp/digests
104
+ pattern : digests-*
105
+ merge-multiple : true
106
+
107
+ - name : Get the last commit short SHA
108
+ uses : ./.github/actions/get-sha
109
+
110
+ - name : Set up Docker Buildx
111
+ uses : docker/setup-buildx-action@v3
112
+
113
+ - name : Docker meta
114
+ id : meta
115
+ uses : docker/metadata-action@v5
116
+ with :
117
+ images : ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}
118
+ tags : |
119
+ type=raw,value=next
120
+ type=ref,prefix=pr-,suffix=-${{ env.SHORT_SHA }},event=pr
121
+
122
+ - name : Login to Docker Hub
123
+ uses : docker/login-action@v3
124
+ with :
125
+ registry : ${{ env.REGISTRY }}
126
+ username : ${{ vars.QUAY_USERNAME }}
127
+ password : ${{ secrets.QUAY_TOKEN }}
128
+
129
+ - name : Create manifest list and push
130
+ working-directory : /tmp/digests
131
+ run : |
132
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
133
+ $(printf '${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
134
+
135
+ - name : Inspect image
136
+ run : |
137
+ docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments