jellyflood/.claude/scripts/create-issue.sh

61 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# Create a Gitea issue for jellyflood
# Usage: ./create-issue.sh "Issue Title" "Issue Body" "feature|bug"
#
set -e
# Load environment variables
source ~/.zshrc
# Gitea configuration
GITEA_URL="https://git.ashik.se"
REPO_OWNER="ashikk"
REPO_NAME="jellyflood"
# Check for API token in environment
if [ -z "$GITEA_API_TOKEN" ]; then
echo "Error: GITEA_API_TOKEN environment variable not set"
echo "Please set it in your ~/.zshrc"
echo "Get a token at: $GITEA_URL/user/settings/applications"
exit 1
fi
# Check arguments
if [ $# -lt 2 ]; then
echo "Usage: $0 \"Issue Title\" \"Issue Body\" [feature|bug]"
echo ""
echo "Example:"
echo " $0 \"jellyflood-8: New Feature\" \"Description here\" \"feature\""
exit 1
fi
TITLE="$1"
BODY="$2"
LABEL="${3:-feature}"
# Add label to body
FULL_BODY="**Label:** $LABEL
$BODY"
# Create issue
echo "Creating issue: $TITLE"
RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITEA_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg title "$TITLE" --arg body "$FULL_BODY" '{title: $title, body: $body}')" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/issues")
ISSUE_NUMBER=$(echo "$RESPONSE" | jq -r '.number // "error"')
if [ "$ISSUE_NUMBER" = "error" ]; then
echo "Error creating issue:"
echo "$RESPONSE" | jq -r '.message // .'
exit 1
fi
echo "✅ Issue #$ISSUE_NUMBER created successfully!"
echo "View at: $GITEA_URL/$REPO_OWNER/$REPO_NAME/issues/$ISSUE_NUMBER"