Fix Build and Push Container Image (#1633)

* fix: Updating cleanup step

* fix: Updated trigger for build-container

* fix: Unset token for cleanup step

* fix: Set build-container cleanup step without run-dry

* fix: Removed 100 commits from checkout actions

* fix: Enable the whole history

* test: Suggestion from mcm007 on build-container

* fix: add token to package cleanup step

Explicitly pass GITHUB_TOKEN to the delete-package-versions action to ensure it has sufficient authorization for package deletion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: - Error: delete version API failed. Package not found.

* fix: Deleted LLAMA_COMMIT from build

* fix: Removed id-token permission

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Yadir Hernandez Batista 2026-04-16 05:24:19 -04:00 committed by GitHub
parent 4945d3b7d0
commit 8df5cbc0b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 21 deletions

View File

@ -1,11 +1,12 @@
name: Build and Push Docker Image
on: workflow_dispatch
on:
# Allows manual triggering of the workflow
workflow_dispatch:
permissions:
contents: read
packages: write
actions: read
jobs:
build-and-push:
@ -28,7 +29,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100 # Enough for rev-list, but saves GBs of history
fetch-depth: 0 # 0 indicates all history for all branches and tags
- name: Free Disk Space (Ubuntu)
run: |
@ -57,7 +58,6 @@ jobs:
id: prep
run: |
echo "BUILD_NUMBER=$(git rev-list --count HEAD)" >> $GITHUB_ENV
echo "LLAMA_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "REPO_LOWER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# 5.1 Restore the cache from GitHub's storage to a host folder
@ -86,7 +86,6 @@ jobs:
REPO_OWNER: ${{ env.REPO_LOWER }}
VARIANT: ${{ matrix.variant }}
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
LLAMA_COMMIT: ${{ env.LLAMA_COMMIT }}
CUDA_VERSION: ${{ matrix.cuda_version }}
GGML_NATIVE: "OFF" # Force OFF for CI portability
USE_CCACHE: "true"
@ -103,18 +102,17 @@ jobs:
cleanup:
runs-on: ubuntu-latest
needs: build-and-push
if: success()
permissions:
packages: write
steps:
- name: Delete untagged images
uses: vlaurin/action-ghcr-prune@v0.6.0
uses: dataaxiom/ghcr-cleanup-action@v1
with:
# Use a PAT if GITHUB_TOKEN continues to return "Not Found"
token: ${{ secrets.GITHUB_TOKEN }}
# Ensure this matches the package owner (user or org)
organization: ${{ github.repository_owner }}
container: ik-llama-cpp
# Changed from untagged-only to the valid input
untagged: true
# Optional: Keep the most recent untagged if needed,
# otherwise 0 deletes all untagged.
keep-last: 0
token: ${{ secrets.GITHUB_TOKEN }}
# Use the lower-case owner env you created earlier if possible,
# or just github.repository_owner
owner: ${{ github.repository_owner }}
package: ik-llama-cpp
delete-untagged: true
# This helps avoid the "Package not found" error during high-volume deletion
validate: false

View File

@ -1,7 +1,6 @@
variable "REPO_OWNER" { default = "local" }
variable "VARIANT" { default = "cpu" }
variable "BUILD_NUMBER" { default = "0" }
variable "LLAMA_COMMIT" { default = "local-dev" }
variable "CUDA_VERSION" {}
variable "CUDA_DOCKER_ARCH" { default = "86;90" }
variable "USE_CCACHE" { default = "true" }
@ -22,7 +21,6 @@ target "settings" {
inherits = ["cache_settings"]
args = {
BUILD_NUMBER = "${BUILD_NUMBER}"
BUILD_COMMIT = "${LLAMA_COMMIT}"
CUDA_VERSION = "${CUDA_VERSION}"
CUDA_DOCKER_ARCH = "${CUDA_DOCKER_ARCH}"
GGML_NATIVE = "${GGML_NATIVE}"
@ -43,7 +41,7 @@ target "full" {
inherits = ["settings"]
target = "full"
tags = [
"ghcr.io/${REPO_OWNER}/ik-llama-cpp:${VARIANT}-full-${BUILD_NUMBER}-${LLAMA_COMMIT}",
"ghcr.io/${REPO_OWNER}/ik-llama-cpp:${VARIANT}-full-${BUILD_NUMBER}",
"ghcr.io/${REPO_OWNER}/ik-llama-cpp:${VARIANT}-full"
]
}
@ -52,7 +50,7 @@ target "swap" {
inherits = ["settings"]
target = "swap"
tags = [
"ghcr.io/${REPO_OWNER}/ik-llama-cpp:${VARIANT}-swap-${BUILD_NUMBER}-${LLAMA_COMMIT}",
"ghcr.io/${REPO_OWNER}/ik-llama-cpp:${VARIANT}-swap-${BUILD_NUMBER}",
"ghcr.io/${REPO_OWNER}/ik-llama-cpp:${VARIANT}-swap"
]
}