publish self-host docker v1.5.28 #52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Self-host Docker Image | |
| run-name: "${{ format('publish self-host docker {0}', inputs.tag) }}" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: Git tag to publish (e.g. v1.5.0) | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: publish-selfhost-docker-${{ inputs.tag }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| HAS_LEGACY_TOKEN: ${{ secrets.GHCR_LEGACY_TOKEN != '' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.11 | |
| - name: Validate release tag | |
| env: | |
| RAW_RELEASE_TAG: ${{ inputs.tag }} | |
| run: bun run scripts/validate-release-ref.ts --tag-env RAW_RELEASE_TAG --write-env RELEASE_TAG | |
| - name: Checkout release tag | |
| env: | |
| GH_TOKEN: ${{ secrets.RELEASE_PAT || github.token }} | |
| run: | | |
| auth_remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
| git fetch --force --tags "$auth_remote" "refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG" | |
| git checkout --detach "$RELEASE_TAG" | |
| - name: Resolve image metadata | |
| id: image | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| version="${RELEASE_TAG#v}" | |
| owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')" | |
| image="ghcr.io/${owner}/executor-selfhost" | |
| legacy_image="ghcr.io/rhyssullivan/executor-selfhost" | |
| revision="$(git rev-parse HEAD)" | |
| if [[ "$version" == *-* ]]; then | |
| channel="beta" | |
| else | |
| channel="latest" | |
| fi | |
| { | |
| echo "image=$image" | |
| echo "version=$version" | |
| echo "channel=$channel" | |
| echo "tags<<TAGS" | |
| echo "${image}:${RELEASE_TAG}" | |
| echo "${image}:${version}" | |
| echo "${image}:${channel}" | |
| echo "TAGS" | |
| echo "legacy_tags<<TAGS" | |
| echo "${legacy_image}:${RELEASE_TAG}" | |
| echo "${legacy_image}:${version}" | |
| echo "${legacy_image}:${channel}" | |
| echo "TAGS" | |
| echo "labels<<LABELS" | |
| echo "org.opencontainers.image.title=Executor self-host" | |
| echo "org.opencontainers.image.description=Single-container self-hosted Executor" | |
| echo "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}" | |
| echo "org.opencontainers.image.revision=${revision}" | |
| echo "org.opencontainers.image.version=${version}" | |
| echo "LABELS" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push self-host image | |
| id: build | |
| uses: useblacksmith/build-push-action@v2 | |
| with: | |
| context: . | |
| file: apps/host-selfhost/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.image.outputs.tags }} | |
| labels: ${{ steps.image.outputs.labels }} | |
| - name: Skip legacy GHCR mirror (GHCR_LEGACY_TOKEN not configured) | |
| if: env.HAS_LEGACY_TOKEN != 'true' | |
| run: echo "GHCR_LEGACY_TOKEN is not configured; skipping legacy GHCR mirror." | |
| - name: Log in to legacy GHCR namespace | |
| if: env.HAS_LEGACY_TOKEN == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: rhyssullivan | |
| password: ${{ secrets.GHCR_LEGACY_TOKEN }} | |
| - name: Mirror self-host image to legacy GHCR namespace | |
| if: env.HAS_LEGACY_TOKEN == 'true' | |
| shell: bash | |
| env: | |
| SOURCE_IMAGE: ${{ steps.image.outputs.image }}@${{ steps.build.outputs.digest }} | |
| LEGACY_TAGS: ${{ steps.image.outputs.legacy_tags }} | |
| run: | | |
| set -euo pipefail | |
| tag_args=() | |
| while IFS= read -r tag; do | |
| [[ -n "$tag" ]] || continue | |
| tag_args+=("-t" "$tag") | |
| done <<< "$LEGACY_TAGS" | |
| docker buildx imagetools create "${tag_args[@]}" "$SOURCE_IMAGE" |