From 83e367afab8a12cef2c49fc58264e72df0b825e4 Mon Sep 17 00:00:00 2001 From: kang-heewon Date: Sun, 22 Mar 2026 15:20:59 +0900 Subject: [PATCH] ci: add GHCR publish workflow for fork deployments --- .github/workflows/ghcr-publish.yml | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/ghcr-publish.yml diff --git a/.github/workflows/ghcr-publish.yml b/.github/workflows/ghcr-publish.yml new file mode 100644 index 0000000000..dbba8a8e1c --- /dev/null +++ b/.github/workflows/ghcr-publish.yml @@ -0,0 +1,72 @@ +name: Publish to GHCR + +on: + release: + types: [published] + workflow_dispatch: + inputs: + version: + description: "Version tag to build (e.g. 2.6.0)" + required: true + type: string + +permissions: + contents: read + packages: write + +jobs: + docker: + name: Build and Push Docker (multi-arch) + runs-on: ubuntu-latest + env: + IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/omniroute + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/v{0}', inputs.version) || '' }} + + - name: Set up QEMU (for multi-arch builds) + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract version from release tag or input + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + VERSION="${{ inputs.version }}" + else + VERSION="${GITHUB_REF_NAME}" + VERSION="${VERSION#v}" + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "Publishing Docker image: $IMAGE_NAME:$VERSION" + + - name: Build and push multi-arch image + uses: docker/build-push-action@v7 + with: + context: . + target: runner-base + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} + ${{ env.IMAGE_NAME }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max + no-cache: false + env: + DOCKER_BUILDKIT_INLINE_CACHE: 1 + + - name: Inspect image + run: | + docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}"