Skip to content

Base Updater

Base Updater #4788

Workflow file for this run

name: Base Updater
on:
schedule:
- cron: '20 */6 * * *'
workflow_dispatch:
env:
REPO: "rclone"
jobs:
base-updater:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4.1.6
- name: Check for updates and trigger
run: |
DISTRO=$(cat Dockerfile | grep 'FROM' | sed 's|.*baseimage-\(.*\):.*|\1|')
TAG=$(cat Dockerfile | grep 'FROM' | sed 's|.*:\(.*\)|\1|')
token=$(curl -sX GET \
"https://ghcr.io/token?scope=repository%3Alinuxserver%2Fbaseimage-${DISTRO}%3Apull" \
| jq -r '.token')
EXTDIGEST=$(curl -I \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Authorization: Bearer ${token}" \
"https://ghcr.io/v2/linuxserver/baseimage-${DISTRO}/manifests/${TAG}" \
| grep 'docker-content-digest' | awk '{print $2}')
if [ -z "${EXTDIGEST}" ]; then
echo "Unable to retrieve external digest. Exiting."
exit 0
else
echo "External digest retrieved: ${EXTDIGEST}"
fi
LASTDIGEST=$(cat baseimage-digest.txt)
if [ "${LASTDIGEST}" != "${EXTDIGEST}" ]; then
echo "Last used baseimage digest: ${LASTDIGEST}"
echo "Baseimage seems to have been updated. Updating baseimage digest and triggering a build."
curl -iX POST \
-H "Authorization: token ${{ secrets.CR_PAT }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"ref\":\"refs/heads/master\"}" \
https://api.github.com/repos/aptalca/${REPO}/actions/workflows/BuildImage.yml/dispatches
echo -n "${EXTDIGEST}" > baseimage-digest.txt
git config --local user.email "bot@aptalca.doot"
git config --local user.name "AptalcaBot"
git add . || :
git commit -m '[bot] Updating baseimage digest' || :
git push || :
else
echo "Baseimage seems to be the same. Skipping."
fi