From fb1adbe8c88909a84f6a0ca34ff2ee1316d7cd49 Mon Sep 17 00:00:00 2001 From: Donato Capitella Date: Thu, 7 Aug 2025 16:46:33 +0100 Subject: [PATCH] Auto trigger build with new releases on llama.cpp --- .github/workflows/poll-llama-cpp.yaml | 77 +++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/poll-llama-cpp.yaml diff --git a/.github/workflows/poll-llama-cpp.yaml b/.github/workflows/poll-llama-cpp.yaml new file mode 100644 index 0000000..65d8178 --- /dev/null +++ b/.github/workflows/poll-llama-cpp.yaml @@ -0,0 +1,77 @@ +name: Poll llama.cpp and Trigger Docker Build + +on: + schedule: + - cron: '*/30 * * * *' # Every 30 minutes + workflow_dispatch: + +jobs: + poll-and-trigger: + runs-on: ubuntu-latest + + steps: + - name: Checkout (needed for artifact access) + uses: actions/checkout@v4 + + - name: Get latest commit from llama.cpp/main + id: fetch + run: | + echo "🔍 Fetching latest commit SHA from llama.cpp..." + LATEST_SHA=$(curl -s https://api.github.com/repos/ggml-org/llama.cpp/commits/main | jq -r .sha) + echo "✅ Latest SHA: $LATEST_SHA" + echo "latest_sha=$LATEST_SHA" >> $GITHUB_OUTPUT + + - name: Download last known SHA artifact + uses: actions/download-artifact@v4 + with: + name: last-llama-sha + continue-on-error: true + + - name: Read last known SHA + id: last + run: | + if [[ -f .last_commit_sha ]]; then + LAST_SHA=$(cat .last_commit_sha) + echo "📦 Found previous SHA: $LAST_SHA" + echo "last_sha=$LAST_SHA" >> $GITHUB_OUTPUT + else + echo "⚠️ No previous SHA found (first run or artifact missing)" + echo "last_sha=" >> $GITHUB_OUTPUT + fi + + - name: Compare SHAs + id: compare + run: | + echo "🧮 Comparing SHAs..." + echo "Previous: ${{ steps.last.outputs.last_sha }}" + echo "Current: ${{ steps.fetch.outputs.latest_sha }}" + if [[ "${{ steps.fetch.outputs.latest_sha }}" != "${{ steps.last.outputs.last_sha }}" ]]; then + echo "🔁 Detected new commit. Triggering build workflow." + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "✅ No changes detected. Skipping trigger." + echo "changed=false" >> $GITHUB_OUTPUT + fi + + - name: Trigger Build & Publish Workflow + if: steps.compare.outputs.changed == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "🚀 Sending workflow_dispatch event to trigger Docker build..." + curl -X POST https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-publish-strix.yml/dispatches \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GH_TOKEN" \ + -d '{"ref":"main","inputs":{"backends":"all"}}' + + - name: Save latest SHA to file + if: steps.compare.outputs.changed == 'true' + run: echo "${{ steps.fetch.outputs.latest_sha }}" > .last_commit_sha + + - name: Upload updated SHA artifact + if: steps.compare.outputs.changed == 'true' + uses: actions/upload-artifact@v4 + with: + name: last-llama-sha + path: .last_commit_sha + retention-days: 2