generate-agenda.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 15:00 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 recently active PRs (updated in last week, but not newly created)
  35. echo "Fetching recently active PRs..."
  36. RECENTLY_ACTIVE_PRS=$(gh pr list \
  37. --repo "$REPO" \
  38. --state open \
  39. --search "updated:>=$SINCE_DATE -created:>=$SINCE_DATE" \
  40. --json number,title,url \
  41. --jq '.[] | [.number, .title, .url] | @tsv' \
  42. 2>/dev/null || echo "")
  43. # Fetch new PRs (opened in the last week)
  44. echo "Fetching new PRs..."
  45. NEW_PRS=$(gh pr list \
  46. --repo "$REPO" \
  47. --state open \
  48. --search "created:>=$SINCE_DATE" \
  49. --json number,title,url \
  50. --jq '.[] | [.number, .title, .url] | @tsv' \
  51. 2>/dev/null || echo "")
  52. # Fetch new issues
  53. echo "Fetching new issues..."
  54. NEW_ISSUES=$(gh issue list \
  55. --repo "$REPO" \
  56. --state open \
  57. --search "created:>=$SINCE_DATE" \
  58. --json number,title,url \
  59. --jq '.[] | [.number, .title, .url] | @tsv' \
  60. 2>/dev/null || echo "")
  61. # Fetch discussion items (labeled with meeting-discussion)
  62. echo "Fetching discussion items..."
  63. DISCUSSION_PRS=$(gh pr list \
  64. --repo "$REPO" \
  65. --state open \
  66. --label "meeting-discussion" \
  67. --json number,title,url \
  68. --jq '.[] | [.number, .title, .url] | @tsv' \
  69. 2>/dev/null || echo "")
  70. DISCUSSION_ISSUES=$(gh issue list \
  71. --repo "$REPO" \
  72. --state open \
  73. --label "meeting-discussion" \
  74. --json number,title,url \
  75. --jq '.[] | [.number, .title, .url] | @tsv' \
  76. 2>/dev/null || echo "")
  77. # Combine discussion items (PRs and issues)
  78. DISCUSSION_ITEMS=$(printf "%s\n%s" "$DISCUSSION_PRS" "$DISCUSSION_ISSUES" | grep -v '^$' || echo "")
  79. # Generate markdown
  80. AGENDA=$(cat <<EOF
  81. # CDK Development Meeting
  82. $MEETING_DATE
  83. Meeting Link: $MEETING_LINK
  84. ## Merged
  85. $(format_list "$MERGED_PRS")
  86. ## New
  87. ### Issues
  88. $(format_list "$NEW_ISSUES")
  89. ### PRs
  90. $(format_list "$NEW_PRS")
  91. ## Recently Active
  92. $(format_list "$RECENTLY_ACTIVE_PRS")
  93. ## Discussion
  94. $(format_list "$DISCUSSION_ITEMS")
  95. EOF
  96. )
  97. echo "$AGENDA"
  98. # Output to file if requested
  99. if [ "${OUTPUT_TO_FILE:-true}" = "true" ]; then
  100. mkdir -p "$OUTPUT_DIR"
  101. OUTPUT_FILE="$OUTPUT_DIR/$FILE_DATE-agenda.md"
  102. echo "$AGENDA" > "$OUTPUT_FILE"
  103. echo "Agenda saved to $OUTPUT_FILE"
  104. fi
  105. # Create GitHub Discussion if requested
  106. if [ "${CREATE_DISCUSSION:-false}" = "true" ]; then
  107. echo "Creating GitHub discussion..."
  108. DISCUSSION_TITLE="CDK Dev Meeting - $MEETING_DATE"
  109. # Note: gh CLI doesn't have direct discussion creation yet, so we'd need to use the API
  110. # For now, we'll just output instructions
  111. echo "To create discussion manually, use the GitHub web interface or API"
  112. echo "Title: $DISCUSSION_TITLE"
  113. fi
  114. # Output for GitHub Actions
  115. if [ -n "$GITHUB_OUTPUT" ]; then
  116. echo "agenda_file=$OUTPUT_FILE" >> "$GITHUB_OUTPUT"
  117. echo "meeting_date=$MEETING_DATE" >> "$GITHUB_OUTPUT"
  118. fi