generate-agenda.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. set -e
  3. # Configuration
  4. REPO="${GITHUB_REPOSITORY:-cashubtc/cdk}"
  5. DAYS_BACK="${DAYS_BACK:-7}"
  6. MEETING_LINK="https://meet.fulmo.org/cdk-dev"
  7. OUTPUT_DIR="meetings"
  8. # Calculate date range (last 7 days)
  9. SINCE_DATE=$(date -d "$DAYS_BACK days ago" -u +"%Y-%m-%dT%H:%M:%SZ")
  10. MEETING_DATE=$(date -u +"%b %d %Y %H:%M UTC")
  11. FILE_DATE=$(date -u +"%Y-%m-%d")
  12. echo "Generating meeting agenda for $MEETING_DATE"
  13. echo "Fetching data since $SINCE_DATE"
  14. # Function to format PR/issue list
  15. format_list() {
  16. local items="$1"
  17. if [ -z "$items" ]; then
  18. echo "- None"
  19. else
  20. echo "$items" | while IFS=$'\t' read -r number title url; do
  21. echo "- [#$number]($url) - $title"
  22. done
  23. fi
  24. }
  25. # Fetch merged PRs
  26. echo "Fetching merged PRs..."
  27. MERGED_PRS=$(gh pr list \
  28. --repo "$REPO" \
  29. --state merged \
  30. --search "merged:>=$SINCE_DATE" \
  31. --json number,title,url \
  32. --jq '.[] | [.number, .title, .url] | @tsv' \
  33. 2>/dev/null || echo "")
  34. # Fetch ongoing (open) PRs
  35. echo "Fetching ongoing PRs..."
  36. ONGOING_PRS=$(gh pr list \
  37. --repo "$REPO" \
  38. --state open \
  39. --json number,title,url,createdAt \
  40. --jq '.[] | select(.createdAt < "'$SINCE_DATE'") | [.number, .title, .url] | @tsv' \
  41. 2>/dev/null || echo "")
  42. # Fetch new PRs (opened in the last week)
  43. echo "Fetching new PRs..."
  44. NEW_PRS=$(gh pr list \
  45. --repo "$REPO" \
  46. --state open \
  47. --search "created:>=$SINCE_DATE" \
  48. --json number,title,url \
  49. --jq '.[] | [.number, .title, .url] | @tsv' \
  50. 2>/dev/null || echo "")
  51. # Fetch new issues
  52. echo "Fetching new issues..."
  53. NEW_ISSUES=$(gh issue list \
  54. --repo "$REPO" \
  55. --state open \
  56. --search "created:>=$SINCE_DATE" \
  57. --json number,title,url \
  58. --jq '.[] | [.number, .title, .url] | @tsv' \
  59. 2>/dev/null || echo "")
  60. # Generate markdown
  61. AGENDA=$(cat <<EOF
  62. # CDK Development Meeting
  63. $MEETING_DATE
  64. Meeting Link: $MEETING_LINK
  65. ## Merged
  66. $(format_list "$MERGED_PRS")
  67. ## Ongoing
  68. $(format_list "$ONGOING_PRS")
  69. ## New
  70. ### Issues
  71. $(format_list "$NEW_ISSUES")
  72. ### PRs
  73. $(format_list "$NEW_PRS")
  74. EOF
  75. )
  76. echo "$AGENDA"
  77. # Output to file if requested
  78. if [ "${OUTPUT_TO_FILE:-true}" = "true" ]; then
  79. mkdir -p "$OUTPUT_DIR"
  80. OUTPUT_FILE="$OUTPUT_DIR/$FILE_DATE-agenda.md"
  81. echo "$AGENDA" > "$OUTPUT_FILE"
  82. echo "Agenda saved to $OUTPUT_FILE"
  83. fi
  84. # Create GitHub Discussion if requested
  85. if [ "${CREATE_DISCUSSION:-false}" = "true" ]; then
  86. echo "Creating GitHub discussion..."
  87. DISCUSSION_TITLE="CDK Dev Meeting - $MEETING_DATE"
  88. # Note: gh CLI doesn't have direct discussion creation yet, so we'd need to use the API
  89. # For now, we'll just output instructions
  90. echo "To create discussion manually, use the GitHub web interface or API"
  91. echo "Title: $DISCUSSION_TITLE"
  92. fi
  93. # Output for GitHub Actions
  94. if [ -n "$GITHUB_OUTPUT" ]; then
  95. echo "agenda_file=$OUTPUT_FILE" >> "$GITHUB_OUTPUT"
  96. echo "meeting_date=$MEETING_DATE" >> "$GITHUB_OUTPUT"
  97. fi