From 4241a66c81d8aaa6fa4cf1b989d7bccc53c16023 Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Mon, 7 Sep 2026 09:15:07 +0200 Subject: [PATCH] Open per-script Node bump PRs This workflow now opens one PR per drifting script instead of batching all Node.js version bumps together. Each PR includes the exact version change, a test command, and a clear decision path for manual review or closure. The summary issue also tracks each script's PR state so drift reporting stays in sync across runs. --- .github/workflows/check-node-versions.yml | 161 ++++++++++++++++++++-- 1 file changed, 153 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check-node-versions.yml b/.github/workflows/check-node-versions.yml index 953721faa..a7b092cee 100644 --- a/.github/workflows/check-node-versions.yml +++ b/.github/workflows/check-node-versions.yml @@ -7,8 +7,9 @@ on: - cron: "0 6 * * 1" permissions: - contents: read + contents: write issues: write + pull-requests: write jobs: check-node-versions: @@ -390,6 +391,129 @@ jobs: cat /tmp/drift_report.md + # One PR per script, not one for all of them: the bumps are judged + # individually (an app can be deliberately held back while the next is a + # safe follow), and a combined PR is blocked by its worst member. + - name: Open a pull request per drifting script + if: steps.check.outputs.drift_count != '0' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + : >/tmp/drift_prs.txt + + while IFS='|' read -r slug our upstream hint repo; do + [[ -z "$slug" ]] && continue + + # "dynamic" and "unset" have no literal to rewrite, and a missing + # upstream major is nothing to rewrite it to. + if [[ ! "$our" =~ ^[0-9]+$ || ! "$upstream" =~ ^[0-9]+$ ]]; then + printf '%s|manual||\n' "$slug" >>/tmp/drift_prs.txt + continue + fi + + # The branch name carries the exact bump, so the PR for it answers + # the question on its own: open means it is waiting for a review, + # closed means someone said no to this bump. A later upstream + # release changes the name and gets its own PR. + branch="node-drift/${slug}-${our}-to-${upstream}" + + existing=$(gh pr list --head "$branch" --state all \ + --json number,state,url,labels --jq '.[0] // empty' 2>/dev/null || echo "") + + if [[ -n "$existing" ]]; then + state=$(jq -r '.state' <<<"$existing") + url=$(jq -r '.url' <<<"$existing") + stale=$(jq -r '[.labels[]?.name] | index("stale") // empty' <<<"$existing") + + case "$state" in + OPEN) + printf '%s|open|%s\n' "$slug" "$url" >>/tmp/drift_prs.txt + continue + ;; + MERGED) + printf '%s|merged|%s\n' "$slug" "$url" >>/tmp/drift_prs.txt + continue + ;; + *) + # The stale bot only closes what a human labelled "stale", so + # that close carries no verdict on the bump — reopen the case. + # A close without it is a decision, and it stands. + if [[ -z "$stale" ]]; then + printf '%s|declined|%s\n' "$slug" "$url" >>/tmp/drift_prs.txt + continue + fi + git push origin --delete "$branch" >/dev/null 2>&1 || true + ;; + esac + fi + + git checkout -q -B "$branch" + + changed=() + for f in "install/${slug}-install.sh" "ct/${slug}.sh"; do + [[ -f "$f" ]] || continue + if grep -qE "NODE_VERSION=\"?${our}\"?" "$f"; then + sed -i -E "s/(NODE_VERSION=)\"?${our}\"?/\1\"${upstream}\"/g" "$f" + changed+=("$f") + fi + done + + if [[ ${#changed[@]} -eq 0 ]]; then + printf '%s|manual||\n' "$slug" >>/tmp/drift_prs.txt + git checkout -q main + continue + fi + + git add "${changed[@]}" + git commit -q -m "${slug}: bump Node.js from ${our} to ${upstream}" + + if ! git push -q -u origin "$branch" 2>/dev/null; then + printf '%s|failed||\n' "$slug" >>/tmp/drift_prs.txt + git checkout -q main + continue + fi + + # The test command is written here rather than left to + # pr-test-command.yml: a PR opened with GITHUB_TOKEN does not start + # another workflow, so that comment would never arrive. + body=$(cat </dev/null); then + gh pr edit "$url" --add-label "automated pr" >/dev/null 2>&1 || true + printf '%s|open|%s\n' "$slug" "$url" >>/tmp/drift_prs.txt + else + printf '%s|failed||\n' "$slug" >>/tmp/drift_prs.txt + fi + + git checkout -q main + done -install.sh\` - 4. Update \`NODE_VERSION\` in \`ct/.sh\` (update section) if applicable - 5. Check off the item above once done + Each item above has its own pull request with the bump already applied and a ready-to-run test command in the description. + + 1. Check the upstream Dockerfile / package.json to confirm the required Node.js version + 2. Run the test command from the PR against a host + 3. Merge the PR if it works — the item disappears from this list on the next run + 4. Close the PR if the bump is wrong: the script stays as it is and this exact bump is never proposed again
Full report