Skip to content

feat: add enterprise GitHub host support and OCI publishing #7

feat: add enterprise GitHub host support and OCI publishing

feat: add enterprise GitHub host support and OCI publishing #7

Workflow file for this run

name: OCI Image
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
workflow_dispatch:
# One in-flight run per ref (PR or branch); newer pushes cancel older runs.
# Tag/release builds get a unique group so they are never cancelled.
concurrency:
group: oci-image-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: read
packages: write
jobs:
build-and-push:
name: Build and Push Image
runs-on: ubuntu-24.04
env:
# Push for branch/tag pushes, manual runs, and same-repo PRs. Fork PRs
# only get a read-only GITHUB_TOKEN, so those build without pushing.
CAN_PUSH: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
# On PRs from forks the GITHUB_TOKEN is read-only and login to GHCR
# would fail, so only log in when we can actually push.
if: env.CAN_PUSH == 'true'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: ${{ env.CAN_PUSH == 'true' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max