80 lines
3.2 KiB
YAML
80 lines
3.2 KiB
YAML
name: 👀 Check for new ollama stable releases and builds a new custom image release if needed
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 8 * * *' # Every day at 8am
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-new-release:
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 5
|
|
|
|
# Output mapping needed to share data between jobs. Separated jobs to reuse the build-and-push.yml workflow.
|
|
outputs:
|
|
has_new_release: ${{ steps.new_release_check.outputs.has_new_release }}
|
|
version_to_release: ${{ steps.ollama_version.outputs.version_to_release }}
|
|
|
|
steps:
|
|
- name: 🆕 Get the latest ollama release
|
|
id: custom_image_release
|
|
uses: dvershinin/lastversion-action@main
|
|
with:
|
|
repository: 'SvenBrnn/runpod-worker-ollama'
|
|
|
|
- name: 🆕 Get the latest ollama release
|
|
id: ollama_release
|
|
uses: dvershinin/lastversion-action@main
|
|
with:
|
|
repository: 'ollama/ollama'
|
|
|
|
- name: 🤲 Check if it is a newer ollama release
|
|
id: new_release_check
|
|
run: |
|
|
echo "👀 Latest Codely custom image release: ${{ steps.custom_image_release.outputs.last_version }}"
|
|
echo "🆕 Latest ollama release: ${{ steps.ollama_release.outputs.last_version }}"
|
|
|
|
custom_version_orig=$(echo "${{ steps.custom_image_release.outputs.last_version }}" | sed 's/ollama@//g')
|
|
custom_version=$(echo "$custom_version_orig" | sed 's/-[0-9]*//g') # Remove the suffix
|
|
ollama_version=$(echo "${{ steps.ollama_release.outputs.last_version }}" | sed 's/ollama@//g')
|
|
|
|
latest_version=$(echo -e "$custom_version\n$ollama_version" | sort -V | tail -n1)
|
|
|
|
if [ "$custom_version" != "$latest_version" ]; then
|
|
echo "has_new_release=true" >> $GITHUB_OUTPUT
|
|
echo "🤩 New release detected! Releasing new custom image version in 1, 2…"
|
|
else
|
|
echo "has_new_release=false" >> $GITHUB_OUTPUT
|
|
echo "👍 Release has not changed or it is previous to the current one. Doing nothing."
|
|
fi
|
|
|
|
- name: 🔡 Remove 'ollama@' from release name to get the version
|
|
id: ollama_version
|
|
if: steps.new_release_check.outputs.has_new_release == 'true'
|
|
run: |
|
|
version_to_release=$(echo "${{ steps.ollama_release.outputs.last_version }}" | sed 's/ollama@//g')
|
|
echo "version_to_release=$version_to_release" >> $GITHUB_OUTPUT
|
|
|
|
patch-dockerfile-and-push:
|
|
needs: check-new-release
|
|
if: ${{ needs.check-new-release.outputs.has_new_release == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Patch Dockerfile with new OLLAMA_VERSION
|
|
run: |
|
|
sed -i '1s/^ARG OLLAMA_VERSION=.*/ARG OLLAMA_VERSION=${{ needs.check-new-release.outputs.version_to_release }}/' Dockerfile
|
|
|
|
- name: Commit and push changes
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add Dockerfile
|
|
git commit -m "chore: bump OLLAMA_VERSION to ${{ needs.check-new-release.outputs.version_to_release }}"
|
|
git push
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|