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

View File

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