Skip to content

Check Base Image Updates #35

Check Base Image Updates

Check Base Image Updates #35

name: Check Base Image Updates
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC
workflow_dispatch:
jobs:
check-update:
name: Check for Sonarr Base Image Updates
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for base image updates
id: check
run: |
echo "πŸ” Checking for Sonarr base image updates..."
# Get latest Sonarr version from LinuxServer API
echo "πŸ“‘ Fetching latest version from LinuxServer API..."
LATEST_VERSION=$(curl -s "https://api.linuxserver.io/api/v1/images" | jq -r '.data.repositories.linuxserver[] | select(.name == "sonarr") | .version')
if [ -z "$LATEST_VERSION" ]; then
echo "❌ Failed to fetch latest version from API"
exit 1
else
echo "βœ… Latest Sonarr version from API: ${LATEST_VERSION}"
fi
echo "latest_version=${LATEST_VERSION}" >> $GITHUB_OUTPUT
# Get current version from VERSION file
echo "πŸ“„ Reading current version from VERSION file..."
if [ -f VERSION ]; then
source VERSION
CURRENT_VERSION="${SONARR_VERSION}"
echo "βœ… Current version in repository: ${CURRENT_VERSION}"
else
echo "❌ VERSION file not found"
exit 1
fi
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
# Check if update is needed
echo ""
echo "πŸ”„ Version comparison:"
echo " Current: ${CURRENT_VERSION}"
echo " Latest: ${LATEST_VERSION}"
if [ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]; then
echo "βœ… Update needed! New version available."
echo "update_needed=true" >> $GITHUB_OUTPUT
else
echo "ℹ️ No update needed. Already on latest version."
echo "update_needed=false" >> $GITHUB_OUTPUT
fi
- name: Update VERSION file
if: steps.check.outputs.update_needed == 'true'
run: |
echo "πŸ“ Updating VERSION file with new version..."
echo "SONARR_VERSION=${{ steps.check.outputs.latest_version }}" > VERSION
echo "βœ… VERSION file updated to: ${{ steps.check.outputs.latest_version }}"
# Show the change
echo ""
echo "πŸ“„ VERSION file content:"
cat VERSION
- name: Create Pull Request
if: steps.check.outputs.update_needed == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update Sonarr base image to ${{ steps.check.outputs.latest_version }}"
title: "Update Sonarr base image to ${{ steps.check.outputs.latest_version }}"
body: |
## πŸš€ Automated Base Image Update
This PR updates the Sonarr base image to version **`${{ steps.check.outputs.latest_version }}`**.
### πŸ“‹ Changes
- Updated `VERSION` file from `${{ steps.check.outputs.current_version }}` to `${{ steps.check.outputs.latest_version }}`
- This will trigger a new Docker image build with the updated Sonarr version
### πŸ”„ What happens next?
1. Review the VERSION file change
2. Merge this PR to trigger the build workflow
3. The build workflow will:
- Read the new version from the VERSION file
- Build a new Docker image with Sonarr `${{ steps.check.outputs.latest_version }}`
- Push to `ghcr.io/${{ github.repository }}` with tags:
- `latest`
- `${{ steps.check.outputs.latest_version }}-<date>`
### πŸ“Š Version Information
- **Previous Version**: `${{ steps.check.outputs.current_version }}`
- **New Version**: `${{ steps.check.outputs.latest_version }}`
- **Source**: LinuxServer.io API
---
*πŸ€– This PR was automatically created by the base image update checker workflow.*
branch: update-sonarr-${{ steps.check.outputs.latest_version }}
delete-branch: true
author: GitHub Actions <noreply@github.com>
committer: Peter Farkas <peter@semmiseg.info>