diff --git a/.github/workflows/ghcr-publish.yml b/.github/workflows/ghcr-publish.yml new file mode 100644 index 000000000..f2dff7aa6 --- /dev/null +++ b/.github/workflows/ghcr-publish.yml @@ -0,0 +1,99 @@ +# Build and push ghcr.io/linkpoolio/docker-images/erpc: from an arbitrary git ref. +# Uses the existing docker-images GHCR namespace (same registry path family as other LinkPool images). +# Auth: GITHUB_TOKEN with packages:write. May require package Actions access for linkpoolio/erpc +# if the package is owned/linked to docker-images. +# +# Run: Actions → "Publish to GHCR" → workflow_dispatch +# tag: sha-1234abc +# ref: main + +name: Publish to GHCR + +concurrency: + group: ghcr-publish-${{ github.event.inputs.tag }} + cancel-in-progress: false + +on: + workflow_dispatch: + inputs: + tag: + description: "Image tag to push (e.g. sha-1234abc)" + required: true + type: string + ref: + description: "Git ref to build (branch, tag, or SHA)" + required: true + default: "main" + type: string + platforms: + description: "Target platforms" + required: false + default: "linux/amd64" + type: string + +permissions: + contents: read + packages: write + +jobs: + publish: + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + fetch-depth: 1 + persist-credentials: false + + - name: Set build metadata + id: meta + env: + INPUT_REF: ${{ inputs.ref }} + INPUT_TAG: ${{ inputs.tag }} + run: | + set -euo pipefail + if [[ ! "$INPUT_TAG" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]]; then + echo "::error::invalid image tag" + exit 1 + fi + SHA="$(git rev-parse HEAD)" + SHORT="$(git rev-parse --short HEAD)" + IMAGE="ghcr.io/linkpoolio/docker-images/erpc" + echo "sha=${SHA}" >> "$GITHUB_OUTPUT" + echo "short_sha=${SHORT}" >> "$GITHUB_OUTPUT" + echo "image=${IMAGE}" >> "$GITHUB_OUTPUT" + echo "Building ref=${INPUT_REF} sha=${SHORT} → ${IMAGE}:${INPUT_TAG}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + platforms: ${{ inputs.platforms }} + tags: | + ${{ steps.meta.outputs.image }}:${{ inputs.tag }} + build-args: | + VERSION=${{ inputs.tag }} + COMMIT_SHA=${{ steps.meta.outputs.short_sha }} + provenance: false + sbom: false + + - name: Print digest + env: + IMAGE: ${{ steps.meta.outputs.image }} + INPUT_TAG: ${{ inputs.tag }} + run: | + docker buildx imagetools inspect "${IMAGE}:${INPUT_TAG}"