Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/ghcr-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Build and push ghcr.io/linkpoolio/docker-images/erpc:<tag> 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}"
Loading