Update Unbound Dockerfile #153
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Unbound Dockerfile | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Run every day at midnight | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Get latest Unbound version | |
id: get_version | |
run: | | |
URL="https://nlnetlabs.nl/downloads/unbound/" | |
CONTENT=$(curl -sL $URL) | |
VERSIONS=$(echo "$CONTENT" | grep -oP 'unbound-\K[\d.]+(?=.tar.gz)') | |
LATEST_VERSION=$(echo "$VERSIONS" | sort -V | tail -n 1) | |
echo "Latest version: $LATEST_VERSION" | |
echo "VERSION=${LATEST_VERSION}" >> $GITHUB_ENV | |
- name: Get SHA256 hash | |
id: get_sha256 | |
run: | | |
URL="https://nlnetlabs.nl/downloads/unbound/unbound-${{ env.VERSION }}.tar.gz.sha256" | |
SHA256_CONTENT=$(curl -sL $URL) | |
SHA256_HASH=$(echo "$SHA256_CONTENT" | awk '{print $1}') | |
echo "Latest SHA256 hash: $SHA256_HASH" | |
echo "SHA256_HASH=${SHA256_HASH}" >> $GITHUB_ENV | |
- name: Check if Dockerfile needs update | |
id: check_dockerfile | |
run: | | |
CURRENT_VERSION=$(grep -oP 'ARG UNBOUND_VERSION=\K[\d.]+' Dockerfile) | |
if [ "$(printf '%s\n' "$CURRENT_VERSION" "${{ env.VERSION }}" | sort -V | head -n1)" = "$CURRENT_VERSION" ] && [ "$CURRENT_VERSION" != "${{ env.VERSION }}" ]; then | |
echo "Dockerfile needs update" | |
echo "UPDATE_DOCKERFILE=true" >> $GITHUB_ENV | |
else | |
echo "Dockerfile is up to date" | |
echo "UPDATE_DOCKERFILE=false" >> $GITHUB_ENV | |
fi | |
- name: Update Dockerfile | |
if: env.UPDATE_DOCKERFILE == 'true' | |
run: | | |
sed -i "s/^ARG UNBOUND_VERSION=.*/ARG UNBOUND_VERSION=${{ env.VERSION }}/" Dockerfile | |
sed -i "s/^ARG UNBOUND_SHA256=.*/ARG UNBOUND_SHA256=${{ env.SHA256_HASH }}/" Dockerfile | |
sed -i "s|^ARG UNBOUND_DOWNLOAD_URL=.*|ARG UNBOUND_DOWNLOAD_URL=https://nlnetlabs.nl/downloads/unbound/unbound-${{ env.VERSION }}.tar.gz|" Dockerfile | |
- name: Create Pull Request | |
if: env.UPDATE_DOCKERFILE == 'true' | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: update-unbound-version | |
commit-message: "chore: Update Unbound version to ${{ env.VERSION }}" | |
title: "chore: Update Unbound version to ${{ env.VERSION }}" | |
body: "This pull request updates the Unbound version in the Dockerfile to ${{ env.VERSION }}." |