Skip to content

Commit 6686db8

Browse files
committed
Publish self-host image to both GHCR namespaces during org transition
1 parent cfd02cf commit 6686db8

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

.github/workflows/publish-selfhost-docker.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
permissions:
2323
contents: read
2424
packages: write
25+
env:
26+
HAS_LEGACY_TOKEN: ${{ secrets.GHCR_LEGACY_TOKEN != '' }}
2527

2628
steps:
2729
- name: Checkout
@@ -57,6 +59,7 @@ jobs:
5759
version="${RELEASE_TAG#v}"
5860
owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"
5961
image="ghcr.io/${owner}/executor-selfhost"
62+
legacy_image="ghcr.io/rhyssullivan/executor-selfhost"
6063
revision="$(git rev-parse HEAD)"
6164
6265
if [[ "$version" == *-* ]]; then
@@ -74,6 +77,11 @@ jobs:
7477
echo "${image}:${version}"
7578
echo "${image}:${channel}"
7679
echo "TAGS"
80+
echo "legacy_tags<<TAGS"
81+
echo "${legacy_image}:${RELEASE_TAG}"
82+
echo "${legacy_image}:${version}"
83+
echo "${legacy_image}:${channel}"
84+
echo "TAGS"
7785
echo "labels<<LABELS"
7886
echo "org.opencontainers.image.title=Executor self-host"
7987
echo "org.opencontainers.image.description=Single-container self-hosted Executor"
@@ -97,6 +105,7 @@ jobs:
97105
password: ${{ secrets.GITHUB_TOKEN }}
98106

99107
- name: Build and push self-host image
108+
id: build
100109
uses: useblacksmith/build-push-action@v2
101110
with:
102111
context: .
@@ -105,3 +114,32 @@ jobs:
105114
push: true
106115
tags: ${{ steps.image.outputs.tags }}
107116
labels: ${{ steps.image.outputs.labels }}
117+
118+
- name: Skip legacy GHCR mirror (GHCR_LEGACY_TOKEN not configured)
119+
if: env.HAS_LEGACY_TOKEN != 'true'
120+
run: echo "GHCR_LEGACY_TOKEN is not configured; skipping legacy GHCR mirror."
121+
122+
- name: Log in to legacy GHCR namespace
123+
if: env.HAS_LEGACY_TOKEN == 'true'
124+
uses: docker/login-action@v3
125+
with:
126+
registry: ghcr.io
127+
username: rhyssullivan
128+
password: ${{ secrets.GHCR_LEGACY_TOKEN }}
129+
130+
- name: Mirror self-host image to legacy GHCR namespace
131+
if: env.HAS_LEGACY_TOKEN == 'true'
132+
shell: bash
133+
env:
134+
SOURCE_IMAGE: ${{ steps.image.outputs.image }}@${{ steps.build.outputs.digest }}
135+
LEGACY_TAGS: ${{ steps.image.outputs.legacy_tags }}
136+
run: |
137+
set -euo pipefail
138+
139+
tag_args=()
140+
while IFS= read -r tag; do
141+
[[ -n "$tag" ]] || continue
142+
tag_args+=("-t" "$tag")
143+
done <<< "$LEGACY_TAGS"
144+
145+
docker buildx imagetools create "${tag_args[@]}" "$SOURCE_IMAGE"

0 commit comments

Comments
 (0)