@lead: issue #16 — fully-automatic autopilot (label-gated @pm auto-delegate + @qa merge)
This commit is contained in:
@@ -51,8 +51,10 @@ git config user.name "$name"
|
||||
git config user.email "$name@ffaerber.duckdns.org"
|
||||
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
hdr=(-H "Authorization: token $TOK" -H "Content-Type: application/json")
|
||||
branch_ref=""
|
||||
if [ -n "$IS_PR" ]; then # comment on a PR -> resume its branch
|
||||
ref=$(curl -s -H "Authorization: token $GT" "$API/pulls/$NUM" | jq -r .head.ref)
|
||||
branch_ref="$ref"
|
||||
git fetch origin "$ref" && git checkout "$ref"
|
||||
{ echo "branch=$ref"; echo "new=false"; } >> "$GITHUB_OUTPUT"
|
||||
elif git ls-remote --exit-code --heads origin "ai/issue-$NUM" >/dev/null 2>&1; then
|
||||
@@ -72,3 +74,18 @@ else # comment on an issue, no branch ye
|
||||
-d "$(jq -nc --arg b "🔨 **@$name** is on it — building on branch [\`ai/issue-$NUM\`]($url). I'll open a PR when it's ready." '{body:$b}')" >/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Autopilot gate: read the `autopilot` label FRESH every run. ---
|
||||
# Presence of this label is the opt-in switch (and the kill switch: remove it mid-flight and the
|
||||
# next run reverts to normal human-approval behavior). When @qa is triggered on a PR thread, the
|
||||
# label lives on the ORIGIN issue (ai/issue-N), so resolve N from the branch name.
|
||||
issnum="$NUM"
|
||||
case "$IS_PR" in ?*) issnum=$(printf '%s' "$branch_ref" | sed -nE 's,^ai/issue-([0-9]+).*,\1,p');; esac
|
||||
[ -z "$issnum" ] && issnum="$NUM"
|
||||
autopilot=false
|
||||
if curl -sS -H "Authorization: token $GT" "$API/issues/$issnum/labels" 2>/dev/null \
|
||||
| jq -e 'any(.[]?; .name=="autopilot")' >/dev/null 2>&1; then
|
||||
autopilot=true
|
||||
fi
|
||||
echo "autopilot (autopilot label on #$issnum)=$autopilot"
|
||||
{ echo "autopilot=$autopilot"; echo "issnum=$issnum"; } >> "$GITHUB_OUTPUT"
|
||||
|
||||
Reference in New Issue
Block a user