name: Build Containers on: # time has no specific meaning, trying to time it after # the llama.cpp daily packages have time to build and publish (~8hr after llama.cpp project's cron) # https://github.com/ggml-org/llama.cpp/blob/master/.github/workflows/docker.yml schedule: - cron: "00 12,18 * * *" # Allows manual triggering of the workflow workflow_dispatch: inputs: dryrun: description: "Run cleanup step in dry-run mode (log what would be deleted, delete nothing)" type: boolean default: false # Run on workflow file changes (without pushing) push: paths: - '.github/workflows/containers.yml' - 'docker/build-container.sh' - 'docker/*.Containerfile' # grant permissions on GITHUB_TOKEN to publish packages # ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#publishing-a-package-using-an-action permissions: contents: read packages: write id-token: write jobs: build-and-push: runs-on: ubuntu-latest strategy: matrix: platform: [intel, cuda, cuda13, vulkan, cpu, musa, rocm] fail-fast: false steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 - name: Free up disk space if: matrix.platform == 'rocm' run: | echo "Before cleanup:" df -h sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/ghc sudo rm -rf /opt/hostedtoolcache/CodeQL sudo docker system prune -af echo "After cleanup:" df -h # QEMU enables arm64 cross-builds on the amd64 GitHub runner. # Currently only the cpu backend goes multi-arch; the action is a # no-op for amd64-only builds, so leaving it on for every matrix # entry keeps the workflow simple. - name: Set up QEMU uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a #v4.0.0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd #v4.0.0 - name: Log in to GitHub Container Registry uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4.1.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Run build-container env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./docker/build-container.sh ${{ matrix.platform }} ${{ github.event_name != 'push' }} # actions/delete-package-versions can't see manifest lists: pushing # a multi-arch image with `docker buildx --push` creates a tagged OCI # index plus one untagged per-platform manifest per arch, and # `delete-only-untagged-versions: true` then nukes the per-platform # children, leaving the index dangling — `docker pull :cpu` 404s on # the referenced digest. dataaxiom/ghcr-cleanup-action walks tagged # manifest lists and excludes their children from deletion. delete-untagged-containers: needs: build-and-push # Skip on forks — the delete API requires package-admin on the # upstream account and would otherwise red-x every fork CI run. if: github.repository == 'mostlygeek/llama-swap' runs-on: ubuntu-latest steps: - uses: dataaxiom/ghcr-cleanup-action@cd0cdb900b5dbf3a6f2cc869f0dbb0b8211f50c4 # v1.0.16 with: token: ${{ secrets.GITHUB_TOKEN }} package: llama-swap delete-untagged: true dry-run: ${{ inputs.dryrun || false }}