#!/bin/bash

# Check if GITHUB_EVENT_PATH exists
if [ ! -f "$GITHUB_EVENT_PATH" ]; then
  echo "GITHUB_EVENT_PATH not found. This script should be run in a GitHub Actions environment."
  exit 1
fi

# Count labels on the pull request
LABEL_COUNT=$(jq '.pull_request.labels | length' "$GITHUB_EVENT_PATH")
echo "Label count is $LABEL_COUNT"

if [ "$LABEL_COUNT" -eq 0 ]; then
  echo "No labels found on this pull request."
  echo "Consider adding labels to categorize this PR (e.g., bug, feature, enhancement)"
  # Option 1: Exit with error (current behavior)
  exit 1
  
  # Option 2: Continue anyway (uncomment the line below and comment out exit 1)
  # echo "Continuing without labels..."
else
  echo "Labels detected. Continuing..."
fi
