#!/usr/bin/env bash # Marks an issue in-progress and creates its branch off the integration branch. # Usage: start-pr.sh ISSUE_NUM BRANCH_NAME set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" . "$HERE/lib.sh" ISSUE="${1:?ISSUE_NUM required}" BRANCH="${2:?BRANCH_NAME required}" # Swap labels: queued -> in-progress QUEUED=$(python -c "import json; print(json.load(open('$LABEL_MAP'))['queue/queued'])") INPROG=$(python -c "import json; print(json.load(open('$LABEL_MAP'))['queue/in-progress'])") api_repo DELETE "issues/$ISSUE/labels/$QUEUED" >/dev/null || true api_repo POST "issues/$ISSUE/labels" "{\"labels\":[$INPROG]}" >/dev/null # Create branch off integration EXISTS=$(api_repo GET "branches/$BRANCH" 2>/dev/null || echo "") if [ -z "$EXISTS" ]; then PAYLOAD=$(python -c "import json; print(json.dumps({'new_branch_name':'$BRANCH','old_branch_name':'$INTEGRATION_BRANCH'}))") api_repo POST branches "$PAYLOAD" >/dev/null echo " branch created: $BRANCH" else echo " branch exists: $BRANCH" fi # Comment COMMENT=$(python -c "import json; print(json.dumps({'body':'🤖 Auto-loop picked this up. Branch: \`$BRANCH\`. Status: in-progress.'}))") api_repo POST "issues/$ISSUE/comments" "$COMMENT" >/dev/null echo " issue #$ISSUE marked in-progress"