4
4
workflow_dispatch :
5
5
push :
6
6
tags :
7
- - " *"
7
+ - " v*"
8
+ pull_request :
9
+ branches :
10
+ - " main"
8
11
9
12
env :
10
13
REGISTRY : ghcr.io
11
- IMAGE_NAMES : " beegfs-all\n beegfs-mgmtd\n beegfs-meta\n beegfs-storage"
14
+ NAMESPACE : thinkparq
15
+ DOCKER_BUILDX_BUILD_PLATFORMS : " linux/amd64,linux/arm64"
12
16
13
17
jobs :
14
18
publish-images :
15
19
runs-on : ubuntu-22.04
16
20
timeout-minutes : 10
21
+ strategy :
22
+ matrix :
23
+ include :
24
+ - image_name : beegfs-all
25
+ - image_name : beegfs-mgmtd
26
+ - image_name : beegfs-meta
27
+ - image_name : beegfs-storage
17
28
permissions :
18
29
packages : write
19
30
contents : read
20
31
steps :
21
32
- uses : actions/checkout@v3
33
+ with :
34
+ fetch-tags : true
35
+ fetch-depth : 0
22
36
23
37
- name : Set up Docker Buildx
24
- uses : docker/setup-buildx-action@v2
38
+ uses : docker/setup-buildx-action@v3
25
39
26
40
- name : Log in to the GitHub Container Registry
27
- uses : docker/login-action@v2
41
+ uses : docker/login-action@v3
28
42
with :
29
43
registry : ${{ env.REGISTRY }}
30
44
username : ${{ github.actor }}
@@ -35,27 +49,60 @@ jobs:
35
49
with :
36
50
cosign-release : " v2.1.1"
37
51
38
- - name : Build, tag, sign, and push the container images to GitHub Container Registry
52
+ - name : Determine what version of BeeGFS to build images for based on the last tag
53
+ id : determine_beegfs_version
39
54
run : |
40
- beegfs_version=$(git describe --tags --match '*.*' --abbrev=10)
41
- names=$(echo "${{ env.IMAGE_NAMES }}" | tr '\n' ' ')
42
-
43
- for name in $names; do
44
- image=ghcr.io/thinkparq/${name}:${beegfs_version}
45
- docker build -t $image --build-arg BEEGFS_VERSION=${beegfs_version} --target ${name} .
46
- docker push $image
55
+ last_version=$(git describe --tags --abbrev=0)
56
+ echo "LAST_VERSION=$last_version" >> $GITHUB_OUTPUT
47
57
48
- DIGEST=$(docker image inspect $image --format '{{index .RepoDigests 0}}')
49
- cosign sign --yes --key env://COSIGN_PRIVATE_KEY \
50
- -a "repo=${{ github.repository }}" \
51
- -a "run=${{ github.run_id }}" \
52
- -a "ref=${{ github.sha }}" \
53
- $DIGEST
58
+ - name : Determine metadata for BeeGFS image
59
+ id : meta
60
+
61
+ with :
62
+ images : ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ matrix.image_name }}
63
+ tags : |
64
+ type=ref,event=branch
65
+ type=ref,event=pr
66
+ type=semver,pattern={{version}},prefix=
67
+ type=semver,pattern={{major}}.{{minor}},prefix=
54
68
55
- docker tag $image ghcr.io/thinkparq/${name}:latest
56
- docker push ghcr.io/thinkparq/${name}:latest
69
+ - name : Build and push image for each supported platform
70
+
71
+ id : build_and_push
72
+ with :
73
+ context : .
74
+ platforms : " ${{ env.DOCKER_BUILDX_BUILD_PLATFORMS }}"
75
+ push : true
76
+ tags : ${{ steps.meta.outputs.tags }}
77
+ labels : ${{ steps.meta.outputs.labels }}
78
+ # If provenance is not set to false then the manifest list will contain unknown platform
79
+ # entries that are also displayed in GitHub. Some detail on why this is needed in:
80
+ # https://github.com/docker/buildx/issues/1509 and
81
+ # https://github.com/docker/build-push-action/issues/755#issuecomment-1607792956.
82
+ provenance : false
83
+ # Reference: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#adding-a-description-to-multi-arch-images
84
+ outputs : type=image,name=target,annotation-index.org.opencontainers.image.description=Container images for the BeeGFS server services allowing fully containerized BeeGFS deployments
85
+ build-args : |
86
+ BEEGFS_VERSION=${{ steps.determine_beegfs_version.outputs.LAST_VERSION }}
87
+ target : ${{ matrix.image_name }}
57
88
89
+ # Adapted from:
90
+ # https://github.blog/2021-12-06-safeguard-container-signing-capability-actions/
91
+ # https://github.com/sigstore/cosign-installer#usage
92
+ # Note we only sign the multi-platform image manifest, not the individual platform specific images.
93
+ - name : Sign container image with Cosign
94
+ run : |
95
+ images=""
96
+ for tag in ${TAGS}; do
97
+ images+="${tag}@${DIGEST} "
58
98
done
99
+ cosign sign --yes --key env://COSIGN_PRIVATE_KEY \
100
+ -a "repo=${{ github.repository }}" \
101
+ -a "run=${{ github.run_id }}" \
102
+ -a "ref=${{ github.sha }}" \
103
+ ${images}
59
104
env :
105
+ TAGS : ${{ steps.meta.outputs.tags }}
60
106
COSIGN_PRIVATE_KEY : ${{ secrets.COSIGN_PRIVATE_KEY }}
61
107
COSIGN_PASSWORD : ${{ secrets.COSIGN_PASSWORD }}
108
+ DIGEST : ${{ steps.build_and_push.outputs.digest }}
0 commit comments