github.repository preserves the owner's mixed-case login (ServeurpersoCom), but GHCR/OCI repository names must be all lowercase, so every docker/build-push-action tag failed with 'repository name must be lowercase'. Co-authored-by: Gary <gitea@gerasch.dev>
66 lines
1.7 KiB
YAML
66 lines
1.7 KiB
YAML
name: Docker
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
tags: ['v*']
|
|
pull_request:
|
|
paths:
|
|
- 'Dockerfile'
|
|
- 'docker/**'
|
|
- '.dockerignore'
|
|
- '.github/workflows/docker.yml'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
variant: [cpu, cuda, vulkan]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Log in to GHCR
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Compute tags
|
|
id: tags
|
|
shell: bash
|
|
run: |
|
|
image="ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')"
|
|
variant="${{ matrix.variant }}"
|
|
tags="${image}:${variant}-${{ github.sha }}"
|
|
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
|
|
tags="${tags},${image}:${variant}"
|
|
fi
|
|
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
|
version="${GITHUB_REF_NAME#v}"
|
|
tags="${tags},${image}:${variant}-v${version}"
|
|
fi
|
|
echo "tags=${tags}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
target: ${{ matrix.variant }}
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.tags.outputs.tags }}
|
|
cache-from: type=gha,scope=${{ matrix.variant }}
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}
|