Skip to content

Check for new pihole version #18

Check for new pihole version

Check for new pihole version #18

name: Check for new pihole version
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
jobs:
docker:
name: Check for new pihole version
runs-on: ubuntu-latest
steps:
- name: ✨ Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 👀 Looking for a new version
id: version-check
run: |
CURRENT_PIHOLE_VERSION=$(cat charts/pihole/Chart.yaml | yq .appVersion)
curl -s 'https://registry.hub.docker.com/v2/repositories/pihole/pihole/tags/' > version.json
LATEST_PIHOLE_DIGEST=$(cat version.json | jq -r '.results[] | select(.name == "latest") | .digest')
LATEST_PIHOLE_VERSION=$(cat version.json | jq -r --arg v "$LATEST_PIHOLE_DIGEST" '.results[] | select(.digest==$v) | select(.name!="latest") | .name')
rm version.json
echo $CURRENT_PIHOLE_VERSION
echo $LATEST_PIHOLE_DIGEST
echo $LATEST_PIHOLE_VERSION
echo "latest_pihole_version=$LATEST_PIHOLE_VERSION" >> "$GITHUB_OUTPUT"
[[ "$LATEST_PIHOLE_VERSION" == "$CURRENT_PIHOLE_VERSION" ]] && echo "new_version=false" || echo "new_version=true" >> "$GITHUB_OUTPUT"
- name: Debug
run: |
echo ${{ steps.version-check.outputs.new_version }}
echo ${{ steps.version-check.outputs.new_version == true }}
echo ${{ steps.version-check.outputs.new_version == 'true' }}
- name: Update version
id: update-version
if: ${{ steps.version-check.outputs.new_version == 'true' }}
run: |
echo "New pihole version: ${{ steps.version-check.outputs.latest_pihole_version }}"
V="${{ steps.version-check.outputs.latest_pihole_version }}" yq -i '.appVersion |= env(V)' charts/pihole/Chart.yaml
- uses: stefanzweifel/git-auto-commit-action@v5
if: ${{ steps.version-check.outputs.new_version == 'true' }}
with:
commit_message: 'feat: Bump pihole version to ${{ steps.version-check.outputs.latest_pihole_version }}'
branch: deps/pihole-version-bump
create_branch: true
- name: 📢 Create new pull request
if: ${{ steps.version-check.outputs.new_version == 'true' }}
run: |
gh pr create -B main -H deps/pihole-version-bump --title 'feat: Bump pihole version to ${{ steps.version-check.outputs.latest_pihole_version }}' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}