name: Upstream patches watch run-name: Watch ps5-linux-patches for new kernel-* tags on: schedule: - cron: '0 4 * * *' workflow_dispatch: permissions: contents: write jobs: check: runs-on: self-hosted env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} steps: - name: Bump build_image.sh PATCHES_REF if stale run: | set -euo pipefail # Read build_image.sh from main via API (no checkout — avoids # EACCES on root-owned build artifacts left in the workspace). gh api "repos/${REPO}/contents/build_image.sh?ref=main" \ --jq '.content' | base64 -d > build_image.sh SHA=$(gh api "repos/${REPO}/contents/build_image.sh?ref=main" --jq '.sha') REPO_URL=$(grep -E '^PATCHES_REPO=' build_image.sh | head -1 | cut -d'"' -f2) if [ "$REPO_URL" != "https://github.com/ps5-linux/ps5-linux-patches.git" ]; then echo "PATCHES_REPO is a fork ($REPO_URL) — skipping auto-bump." exit 0 fi LATEST=$(gh api repos/ps5-linux/ps5-linux-patches/tags --paginate \ --jq '.[] | select(.name | test("^kernel-[0-9]+\\.[0-9]+\\.[0-9]+-[a-f0-9]+$")) | .name' \ | head -1) [ -n "$LATEST" ] || { echo "no kernel tags found"; exit 1; } CUR=$(grep -E '^PATCHES_REF=' build_image.sh | head -1 | cut -d'"' -f2) echo "upstream latest: $LATEST" echo "current ref: $CUR" if [ "$LATEST" = "$CUR" ]; then echo "already current — no bump." exit 0 fi sed -i "s|^PATCHES_REF=\"${CUR}\"|PATCHES_REF=\"${LATEST}\"|" build_image.sh NEW_B64=$(base64 -w0 < build_image.sh) gh api -X PUT "repos/${REPO}/contents/build_image.sh" \ -f message="kernel: auto-bump ${CUR} -> ${LATEST}" \ -f content="${NEW_B64}" \ -f sha="${SHA}" \ -f branch=main \ -f committer.name="ps5-linux-bot" \ -f committer.email="ps5-linux-bot@users.noreply.github.com" echo "pushed bump to ${LATEST}"