Skip to content

Commit 56df897

Browse files
committed
merge after all builds
1 parent 6cfe497 commit 56df897

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,41 @@ jobs:
110110
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
111111
./scripts/publish-arm.sh "main"
112112
fi
113+
merge:
114+
name: 'Merge Labels'
115+
needs: ["build-x86_64", "build-arm64"]
116+
runs-on: ubuntu-24.04
117+
permissions:
118+
contents: read
119+
packages: write
120+
id-token: write
121+
122+
steps:
123+
- name: Checkout (GitHub)
124+
uses: actions/checkout@v3
125+
126+
- name: Login to GitHub Container Registry
127+
uses: docker/login-action@v2
128+
with:
129+
registry: ghcr.io
130+
username: ${{ github.actor }}
131+
password: ${{ secrets.GITHUB_TOKEN }}
132+
133+
# Use .devcontainer from THIS repo for building and testing
134+
- name: Merge
135+
uses: devcontainers/[email protected]
136+
with:
137+
# The .devcontainer is never published as pre-built container.
138+
# We want to only use it for building and testing the actual container, which resides in src/s-core-devcontainer.
139+
push: "never"
140+
runCmd: |
141+
set -eux pipefail
142+
143+
# Optionally: Merge
144+
# We do not use the push feature of devcontainers/ci here, since that would push the wrong container.
145+
# Instead, we use the publish script which pushes the correct container (residing in src/s-core-devcontainer).
146+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
147+
# manually login to ghcr.io for publishing
148+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
149+
./scripts/merge.sh "main"
150+
fi

scripts/merge.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
if [ "$#" -eq 0 ]; then
5+
echo "Error: At least one parameter (label) must be provided."
6+
exit 1
7+
fi
8+
9+
LABELS=()
10+
for LABEL in "$@"; do
11+
LABELS+=("${LABEL}")
12+
done
13+
14+
# Define target architectures
15+
ARCHITECTURES=("amd64", "arm64")
16+
17+
# Create and push the merged multiarch manifest for each tag; each tag combines all architecture-specific tags into one tag
18+
for LABEL in "${LABELS[@]}"; do
19+
echo "Merging all architectures (${ARCHITECTURES[@]}) into single tag: ${LABEL}"
20+
21+
MANIFEST_MERGE_CALL="docker buildx imagetools create -t ghcr.io/eclipse-score/devcontainer:${LABEL}"
22+
23+
for ARCH in "${ARCHITECTURES[@]}"; do
24+
MANIFEST_MERGE_CALL+=" ghcr.io/eclipse-score/devcontainer:${LABEL}-${ARCH}"
25+
done
26+
27+
eval "$MANIFEST_MERGE_CALL"
28+
done

0 commit comments

Comments
 (0)