Files
computer-playbook/scripts/github/update/open_role_prs.sh
T
kevinveenbirkenbachandClaude Opus 4.8 e55001e849 feat(update): one PR per role and compute diffs from latest main
The roles updaters (Docker image versions, repository refs) opened a
single combined PR for all role changes, and the jobs checked out the
trigger commit (actions/checkout default), so updates were computed
against a stale tree and could re-propose already-merged changes.

- Check out 'ref: main' in all update jobs so the diff is always
  computed against the latest main tip at run time.
- Add open_role_prs.sh: split the working-tree changes per role and
  open one isolated branch/PR per changed role, reusing open_pr.sh for
  the dedup/push/PR logic (new UPDATE_DEDUPE_PREFIX hook scopes the
  duplicate check per role; default preserves prior single-PR behavior
  for the skills job).
- Wire the Docker and repository-refs jobs to open_role_prs.sh; skills
  stays a single PR.

Branch: update/<type>-<role>-<date>-<fp>; commit/title gain a (<role>)
suffix and a Scope line.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 19:58:54 +02:00

61 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Opens one update PR per top-level entry that changed under the given root
# (e.g. one PR per role under roles/), instead of a single combined PR.
# The actual dedup/push/PR logic is reused from open_pr.sh; this wrapper only
# isolates one entry's changes per call.
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
ROOT="${1:?Usage: open_role_prs.sh <root-dir> (e.g. roles)}"
: "${GH_TOKEN:?Missing GH_TOKEN}"
: "${UPDATE_BRANCH_PREFIX:?Missing UPDATE_BRANCH_PREFIX}"
: "${UPDATE_COMMIT_MESSAGE:?Missing UPDATE_COMMIT_MESSAGE}"
: "${UPDATE_PR_TITLE:?Missing UPDATE_PR_TITLE}"
: "${UPDATE_PR_BODY:?Missing UPDATE_PR_BODY}"
date_suffix="$(date +%Y%m%d)"
# A throwaway identity is enough for the scratch commit below; open_pr.sh sets
# the real bot identity for each published commit.
git config user.name >/dev/null 2>&1 || git config user.name "github-actions[bot]"
git config user.email >/dev/null 2>&1 || git config user.email "github-actions[bot]@users.noreply.github.com"
base="$(git rev-parse HEAD)"
git add -A -- "${ROOT}"
if git diff --cached --quiet; then
echo "No ${ROOT} changes to split into per-entry PRs."
exit 0
fi
git commit --quiet -m "scratch: ${ROOT} updates"
scratch="$(git rev-parse HEAD)"
git reset --quiet --hard "${base}"
mapfile -t entries < <(
git diff --name-only "${base}" "${scratch}" -- "${ROOT}/" |
sed -E "s#^${ROOT}/([^/]+)/.*#\1#;t;d" |
sort -u
)
echo "Changed ${ROOT} entries: ${entries[*]:-(none)}"
for entry in "${entries[@]}"; do
[[ -z "${entry}" ]] && continue
echo "=== Opening PR for ${ROOT}/${entry} ==="
git checkout --quiet --force --detach "${base}"
git checkout --quiet "${scratch}" -- "${ROOT}/${entry}/"
UPDATE_BRANCH_SUFFIX="${entry}-${date_suffix}" \
UPDATE_DEDUPE_PREFIX="${UPDATE_BRANCH_PREFIX}-${entry}-" \
UPDATE_COMMIT_MESSAGE="${UPDATE_COMMIT_MESSAGE} (${entry})" \
UPDATE_PR_TITLE="${UPDATE_PR_TITLE} (${entry})" \
UPDATE_PR_BODY="${UPDATE_PR_BODY}"$'\n\n'"Scope: \`${ROOT}/${entry}\`." \
bash "${SCRIPT_DIR}/open_pr.sh" "${ROOT}/${entry}"
done
git checkout --quiet --force --detach "${base}" || true