1515 IMAGE : ghcr.io/spacedriveapp/spacebot
1616
1717jobs :
18- build-and-push :
19- runs-on : ubuntu-latest
18+ build :
19+ strategy :
20+ matrix :
21+ include :
22+ - runner : ubuntu-24.04
23+ platform : linux/amd64
24+ - runner : ubuntu-24.04-arm
25+ platform : linux/arm64
26+ runs-on : ${{ matrix.runner }}
2027 permissions :
21- contents : write
28+ contents : read
2229 packages : write
30+ outputs :
31+ version : ${{ steps.version.outputs.version }}
2332
2433 steps :
2534 - uses : actions/checkout@v4
@@ -46,30 +55,66 @@ jobs:
4655 fi
4756 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4857
58+ - name : Platform pair
59+ id : platform
60+ run : echo "pair=$(echo ${{ matrix.platform }} | tr '/' '-')" >> "$GITHUB_OUTPUT"
61+
4962 - name : Build and push slim
5063 uses : docker/build-push-action@v6
5164 with :
5265 context : .
5366 target : slim
67+ platforms : ${{ matrix.platform }}
5468 push : true
55- tags : |
56- ${{ env.IMAGE }}:${{ steps.version.outputs.version }}-slim
57- ${{ env.IMAGE }}:slim
58- cache-from : type=gha
59- cache-to : type=gha,mode=max
69+ tags : ${{ env.IMAGE }}:slim-${{ steps.platform.outputs.pair }}
70+ cache-from : type=gha,scope=slim-${{ steps.platform.outputs.pair }}
71+ cache-to : type=gha,mode=max,scope=slim-${{ steps.platform.outputs.pair }}
6072
6173 - name : Build and push full
6274 uses : docker/build-push-action@v6
6375 with :
6476 context : .
6577 target : full
78+ platforms : ${{ matrix.platform }}
6679 push : true
67- tags : |
68- ${{ env.IMAGE }}:${{ steps.version.outputs.version }}-full
69- ${{ env.IMAGE }}:full
70- ${{ env.IMAGE }}:latest
71- cache-from : type=gha
72- cache-to : type=gha,mode=max
80+ tags : ${{ env.IMAGE }}:full-${{ steps.platform.outputs.pair }}
81+ cache-from : type=gha,scope=full-${{ steps.platform.outputs.pair }}
82+ cache-to : type=gha,mode=max,scope=full-${{ steps.platform.outputs.pair }}
83+
84+ merge :
85+ needs : build
86+ runs-on : ubuntu-24.04
87+ permissions :
88+ contents : write
89+ packages : write
90+
91+ steps :
92+ - name : Set up Docker Buildx
93+ uses : docker/setup-buildx-action@v3
94+
95+ - name : Log in to GHCR
96+ uses : docker/login-action@v3
97+ with :
98+ registry : ${{ env.REGISTRY }}
99+ username : ${{ github.actor }}
100+ password : ${{ secrets.GITHUB_TOKEN }}
101+
102+ - name : Create slim multi-arch manifest
103+ run : |
104+ docker buildx imagetools create \
105+ --tag ${{ env.IMAGE }}:${{ needs.build.outputs.version }}-slim \
106+ --tag ${{ env.IMAGE }}:slim \
107+ ${{ env.IMAGE }}:slim-linux-amd64 \
108+ ${{ env.IMAGE }}:slim-linux-arm64
109+
110+ - name : Create full multi-arch manifest
111+ run : |
112+ docker buildx imagetools create \
113+ --tag ${{ env.IMAGE }}:${{ needs.build.outputs.version }}-full \
114+ --tag ${{ env.IMAGE }}:full \
115+ --tag ${{ env.IMAGE }}:latest \
116+ ${{ env.IMAGE }}:full-linux-amd64 \
117+ ${{ env.IMAGE }}:full-linux-arm64
73118
74119 - name : Log in to Fly registry
75120 uses : docker/login-action@v3
81126 - name : Push to Fly registry
82127 run : |
83128 docker buildx imagetools create \
84- --tag registry.fly.io/spacebot-image:${{ steps.version .outputs.version }} \
129+ --tag registry.fly.io/spacebot-image:${{ needs.build .outputs.version }} \
85130 --tag registry.fly.io/spacebot-image:latest \
86131 ${{ env.IMAGE }}:latest
87132
@@ -91,12 +136,11 @@ jobs:
91136 curl -sf -X POST https://api.spacebot.sh/api/admin/rollout \
92137 -H "Content-Type: application/json" \
93138 -H "X-Internal-Key: ${{ secrets.PLATFORM_INTERNAL_KEY }}" \
94- -d '{"image_tag": "${{ steps.version .outputs.version }}"}'
139+ -d '{"image_tag": "${{ needs.build .outputs.version }}"}'
95140
96141 - name : Create GitHub Release
97142 if : startsWith(github.ref, 'refs/tags/v')
98143 uses : softprops/action-gh-release@v2
99144 with :
100- tag_name : ${{ steps.version .outputs.version }}
145+ tag_name : ${{ needs.build .outputs.version }}
101146 generate_release_notes : true
102-
0 commit comments