Skip to content

Commit 56fd462

Browse files
authored
feat(ci): publish build images to the GitHub Container Registry (#22694)
* feat(ci): publish build images to the GitHub Container Registry * fix typo * try with / vs : * Revert "try with / vs :" This reverts commit 46a7243. * build once, multiple tags, multiple pushes * update scripts/test-e2e-kubernetes.sh
1 parent 48348ff commit 56fd462

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

.github/workflows/publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,12 @@ jobs:
522522
with:
523523
username: ${{ secrets.CI_DOCKER_USERNAME }}
524524
password: ${{ secrets.CI_DOCKER_PASSWORD }}
525+
- name: Login to GitHub Container Registry
526+
uses: docker/login-action@v3
527+
with:
528+
registry: ghcr.io
529+
username: ${{ github.actor }}
530+
password: ${{ secrets.GITHUB_TOKEN }}
525531
- name: Set up QEMU
526532
uses: docker/[email protected]
527533
with:
@@ -575,6 +581,7 @@ jobs:
575581
- name: Build and publish Docker images
576582
env:
577583
PLATFORM: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6"
584+
REPOS: "timberio/vector,ghcr.io/vectordotdev/vector"
578585
uses: nick-fields/retry@v3
579586
with:
580587
timeout_minutes: 15

scripts/build-docker.sh

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ VERSION="${VECTOR_VERSION:-"$(cargo vdev version)"}"
1515
DATE="${DATE:-"$(date -u +%Y-%m-%d)"}"
1616
PLATFORM="${PLATFORM:-}"
1717
PUSH="${PUSH:-"true"}"
18-
REPO="${REPO:-"timberio/vector"}"
18+
REPOS="${REPOS:-"timberio/vector"}"
19+
IFS=, read -ra REPO_LIST <<< "$REPOS"
1920

2021
IFS=, read -ra REQUESTED_PLATFORMS <<< "$PLATFORM"
2122
declare -A SUPPORTED_PLATFORMS=(
@@ -50,42 +51,50 @@ evaluate_supported_platforms_for_base() {
5051
build() {
5152
local BASE="$1"
5253
local VERSION="$2"
53-
54-
local TAG="$REPO:$VERSION-$BASE"
5554
local DOCKERFILE="distribution/docker/$BASE/Dockerfile"
55+
local BUILDABLE_PLATFORMS=""
56+
if [ -n "$PLATFORM" ]; then
57+
BUILDABLE_PLATFORMS=$(evaluate_supported_platforms_for_base "$BASE")
58+
fi
5659

60+
# Collect all tags
61+
TAGS=()
62+
for REPO in "${REPO_LIST[@]}"; do
63+
TAGS+=(--tag "$REPO:$VERSION-$BASE")
64+
done
65+
66+
# Build once with all tags
5767
if [ -n "$PLATFORM" ]; then
5868
ARGS=()
5969
if [[ "$PUSH" == "true" ]]; then
6070
ARGS+=(--push)
6171
fi
6272

63-
local BUILDABLE_PLATFORMS
64-
BUILDABLE_PLATFORMS=$(evaluate_supported_platforms_for_base "$BASE")
65-
6673
docker buildx build \
6774
--platform="$BUILDABLE_PLATFORMS" \
68-
--tag "$TAG" \
75+
"${TAGS[@]}" \
6976
target/artifacts \
7077
-f "$DOCKERFILE" \
7178
"${ARGS[@]}"
7279
else
7380
docker build \
74-
--tag "$TAG" \
81+
"${TAGS[@]}" \
7582
target/artifacts \
7683
-f "$DOCKERFILE"
7784

78-
if [[ "$PUSH" == "true" ]]; then
85+
if [[ "$PUSH" == "true" ]]; then
86+
for TAG in "${TAGS[@]}"; do
7987
docker push "$TAG"
80-
fi
88+
done
89+
fi
8190
fi
8291
}
8392

8493
#
8594
# Build
8695
#
8796

88-
echo "Building $REPO:* Docker images"
97+
echo "Building Docker images for $REPOS"
8998

9099
if [[ "$CHANNEL" == "release" ]]; then
91100
VERSION_EXACT="$VERSION"

scripts/test-e2e-kubernetes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ if [[ -z "${CONTAINER_IMAGE:-}" ]]; then
107107

108108
# Build docker image with Vector - the same way it's done for releases. Don't
109109
# do the push - we'll handle it later.
110-
REPO="$CONTAINER_IMAGE_REPO" \
110+
REPOS="$CONTAINER_IMAGE_REPO" \
111111
CHANNEL="test" \
112112
BASE="$BASE_TAG" \
113113
TAG="$VERSION_TAG" \

0 commit comments

Comments
 (0)