Build Headless Anki Docker image #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Headless Anki Docker image | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Image tag' | |
required: true | |
type: string | |
default: 'main' | |
qt_version: | |
description: 'QT version' | |
required: false | |
type: string | |
default: '6' | |
anki_version: | |
description: 'Anki version' | |
required: false | |
type: string | |
default: '24.06.3' | |
ankiconnect_version: | |
description: 'AnkiConnect version' | |
required: false | |
type: string | |
default: '24.7.25.0' | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
attestations: write | |
steps: | |
- name: Set image name | |
id: image-name | |
run: | | |
echo "name=${GITHUB_REPOSITORY,,}-headless-anki" >> $GITHUB_OUTPUT | |
- name: Set environment variables | |
run: | | |
echo "IMAGE_NAME=${{ steps.image-name.outputs.name }}" >> $GITHUB_ENV | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Checkout Anki repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ankitects/anki | |
path: anki | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Anki Docker image | |
run: | | |
cd anki/.buildkite/linux/docker | |
docker buildx create --use | |
docker run --privileged --rm tonistiigi/binfmt --install all | |
DOCKER_BUILDKIT=1 docker buildx build --platform linux/amd64,linux/arm64 --push \ | |
--tag ${REGISTRY}/${IMAGE_NAME}-base:${{ inputs.tag }} . | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=${{ inputs.tag }} | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | |
with: | |
context: . | |
file: ./Dockerfile.headless-anki | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
ANKI_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-base:${{ inputs.tag }} | |
QT_VERSION=${{ inputs.qt_version }} | |
ANKI_VERSION=${{ inputs.anki_version }} | |
ANKICONNECT_VERSION=${{ inputs.ankiconnect_version }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |