smlflg's picture
Initial public upload from Projekte/AgentProjectMinenraeumer (part 7)
38e8b56 verified
Raw History Blame Contribute Delete
1.16 kB
#!/usr/bin/env bash
set -euo pipefail
# Human-gated script. Do not run blindly.
# Usage after reviewing drafts:
# DRY_RUN=1 ./github/gh_create_issues.sh
# DRY_RUN=0 ./github/gh_create_issues.sh
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
DRAFT_DIR="$ROOT/github/issue_drafts"
DRY_RUN="${DRY_RUN:-1}"
if ! command -v gh >/dev/null 2>&1; then
echo "gh CLI not found" >&2
exit 2
fi
gh auth status >/dev/null
find "$DRAFT_DIR" -type f -name '*.md' | sort | while read -r draft; do
title="$(grep -m1 '^Title:' "$draft" | sed 's/^Title:[[:space:]]*//')"
repo="$(grep -m1 '^Repo:' "$draft" | sed 's/^Repo:[[:space:]]*//')"
labels="$(grep -m1 '^Labels:' "$draft" | sed 's/^Labels:[[:space:]]*//')"
if [[ -z "$title" || -z "$repo" ]]; then
echo "SKIP missing Title/Repo: $draft" >&2
continue
fi
echo "ISSUE draft=$draft repo=$repo title=$title labels=$labels"
if [[ "$DRY_RUN" == "0" ]]; then
if [[ -n "$labels" ]]; then
gh issue create --repo "$repo" --title "$title" --body-file "$draft" --label "$labels"
else
gh issue create --repo "$repo" --title "$title" --body-file "$draft"
fi
fi
done