|
| 1 | +name: Buddy Dashboard Management |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 9 * * 1,3,5' # Monday, Wednesday, Friday at 9 AM UTC |
| 6 | + workflow_dispatch: # Manual triggering |
| 7 | + inputs: |
| 8 | + pin: |
| 9 | + description: Pin the dashboard issue |
| 10 | + required: false |
| 11 | + default: true |
| 12 | + type: boolean |
| 13 | + title: |
| 14 | + description: Custom dashboard title |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + issue_number: |
| 18 | + description: Specific issue number to update |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + verbose: |
| 22 | + description: Enable verbose logging |
| 23 | + required: false |
| 24 | + default: true |
| 25 | + type: boolean |
| 26 | + dry_run: |
| 27 | + description: Dry run (preview only) |
| 28 | + required: false |
| 29 | + default: false |
| 30 | + type: boolean |
| 31 | + |
| 32 | +env: |
| 33 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | +permissions: |
| 36 | + contents: read |
| 37 | + pull-requests: read |
| 38 | + issues: write |
| 39 | + actions: read |
| 40 | + checks: read |
| 41 | + statuses: read |
| 42 | + |
| 43 | +jobs: |
| 44 | + update-dashboard: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout repository |
| 49 | + uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + |
| 53 | + - name: Setup Bun |
| 54 | + uses: oven-sh/setup-bun@v2 |
| 55 | + with: |
| 56 | + bun-version: latest |
| 57 | + |
| 58 | + - name: Install dependencies |
| 59 | + run: bun install |
| 60 | + |
| 61 | + - name: Build buddy-bot |
| 62 | + run: bun run build |
| 63 | + |
| 64 | + - name: Display dashboard configuration |
| 65 | + run: | |
| 66 | + echo "📊 **Buddy Bot Dashboard Management**" |
| 67 | + echo "Pin Dashboard: ${{ github.event.inputs.pin || 'true' }}" |
| 68 | + echo "Custom Title: ${{ github.event.inputs.title || 'default' }}" |
| 69 | + echo "Issue Number: ${{ github.event.inputs.issue_number || 'auto-detect' }}" |
| 70 | + echo "Verbose: ${{ github.event.inputs.verbose || 'true' }}" |
| 71 | + echo "Dry Run: ${{ github.event.inputs.dry_run || 'false' }}" |
| 72 | + echo "Triggered by: ${{ github.event_name }}" |
| 73 | + echo "Repository: ${{ github.repository }}" |
| 74 | + echo "Branch: ${{ github.ref_name }}" |
| 75 | +
|
| 76 | + - name: Update Dependency Dashboard |
| 77 | + run: | |
| 78 | + PIN="${{ github.event.inputs.pin || 'true' }}" |
| 79 | + TITLE="${{ github.event.inputs.title }}" |
| 80 | + ISSUE_NUMBER="${{ github.event.inputs.issue_number }}" |
| 81 | + VERBOSE="${{ github.event.inputs.verbose || 'true' }}" |
| 82 | + DRY_RUN="${{ github.event.inputs.dry_run || 'false' }}" |
| 83 | +
|
| 84 | + echo "📊 Updating dependency dashboard..." |
| 85 | + echo "Pin: $PIN" |
| 86 | + echo "Title: ${TITLE:-default}" |
| 87 | + echo "Issue Number: ${ISSUE_NUMBER:-auto-detect}" |
| 88 | + echo "Verbose: $VERBOSE" |
| 89 | + echo "Dry Run: $DRY_RUN" |
| 90 | + echo "" |
| 91 | +
|
| 92 | + set -e # Exit on any error |
| 93 | +
|
| 94 | + # Build the command |
| 95 | + COMMAND="bun buddy dashboard" |
| 96 | +
|
| 97 | + if [ "$PIN" = "true" ]; then |
| 98 | + COMMAND="$COMMAND --pin" |
| 99 | + fi |
| 100 | +
|
| 101 | + if [ "$TITLE" != "" ]; then |
| 102 | + COMMAND="$COMMAND --title \"$TITLE\"" |
| 103 | + fi |
| 104 | +
|
| 105 | + if [ "$ISSUE_NUMBER" != "" ]; then |
| 106 | + COMMAND="$COMMAND --issue-number \"$ISSUE_NUMBER\"" |
| 107 | + fi |
| 108 | +
|
| 109 | + if [ "$VERBOSE" = "true" ]; then |
| 110 | + COMMAND="$COMMAND --verbose" |
| 111 | + fi |
| 112 | +
|
| 113 | + if [ "$DRY_RUN" = "true" ]; then |
| 114 | + echo "📋 DRY RUN MODE - Command that would be executed:" |
| 115 | + echo "$COMMAND" |
| 116 | + echo "" |
| 117 | + echo "ℹ️ In dry run mode, dashboard content would be generated but no issue would be created/updated" |
| 118 | +
|
| 119 | + # Run scan to show what would be included |
| 120 | + echo "🔍 Scanning for dependencies that would be included:" |
| 121 | + if [ "$VERBOSE" = "true" ]; then |
| 122 | + bun buddy scan --verbose |
| 123 | + else |
| 124 | + bun buddy scan |
| 125 | + fi |
| 126 | + else |
| 127 | + echo "🚀 Executing dashboard update:" |
| 128 | + echo "$COMMAND" |
| 129 | + echo "" |
| 130 | + eval "$COMMAND" |
| 131 | + fi |
| 132 | +
|
| 133 | + env: |
| 134 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 135 | + |
| 136 | + - name: Dry run notification |
| 137 | + if: ${{ github.event.inputs.dry_run == 'true' }} |
| 138 | + run: | |
| 139 | + echo "ℹ️ **Dry Run Mode** - Dashboard preview completed" |
| 140 | + echo "To actually update the dashboard, run this workflow again with 'Dry run' set to false" |
| 141 | +
|
| 142 | + - name: Check dashboard status |
| 143 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
| 144 | + run: | |
| 145 | + echo "✅ Dashboard update completed" |
| 146 | + echo "🔗 Check your repository issues for the updated dependency dashboard" |
| 147 | +
|
| 148 | + # Try to find and link to the dashboard issue |
| 149 | + echo "📊 Looking for dependency dashboard issue..." |
| 150 | +
|
| 151 | + # Use GitHub CLI to find the dashboard issue |
| 152 | + if command -v gh &> /dev/null; then |
| 153 | + DASHBOARD_URL=$(gh issue list --label "dashboard,dependencies" --state open --limit 1 --json url --jq '.[0].url' 2>/dev/null || echo "") |
| 154 | + if [ "$DASHBOARD_URL" != "null" ] && [ "$DASHBOARD_URL" != "" ]; then |
| 155 | + echo "🎯 Dashboard found: $DASHBOARD_URL" |
| 156 | + else |
| 157 | + echo "🔍 Dashboard issue not found via CLI, check issues manually" |
| 158 | + fi |
| 159 | + else |
| 160 | + echo "💡 Check your issues tab for the dependency dashboard" |
| 161 | + fi |
| 162 | +
|
| 163 | + - name: Create dashboard summary |
| 164 | + if: always() |
| 165 | + run: | |
| 166 | + echo "## 📊 Dependency Dashboard Summary" >> $GITHUB_STEP_SUMMARY |
| 167 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 168 | + echo "- **Pin Dashboard**: ${{ github.event.inputs.pin || 'true' }}" >> $GITHUB_STEP_SUMMARY |
| 169 | + echo "- **Custom Title**: ${{ github.event.inputs.title || 'default' }}" >> $GITHUB_STEP_SUMMARY |
| 170 | + echo "- **Issue Number**: ${{ github.event.inputs.issue_number || 'auto-detect' }}" >> $GITHUB_STEP_SUMMARY |
| 171 | + echo "- **Triggered by**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY |
| 172 | + echo "- **Dry run**: ${{ github.event.inputs.dry_run || 'false' }}" >> $GITHUB_STEP_SUMMARY |
| 173 | + echo "- **Verbose**: ${{ github.event.inputs.verbose || 'true' }}" >> $GITHUB_STEP_SUMMARY |
| 174 | + echo "- **Time**: $(date)" >> $GITHUB_STEP_SUMMARY |
| 175 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 176 | +
|
| 177 | + if [ "${{ github.event_name }}" = "schedule" ]; then |
| 178 | + echo "⏰ **Scheduled Update**: This was triggered automatically" >> $GITHUB_STEP_SUMMARY |
| 179 | + echo "🔄 **Schedule**: Monday, Wednesday, Friday at 9 AM UTC" >> $GITHUB_STEP_SUMMARY |
| 180 | + echo "💡 **Tip**: Use 'Actions' tab to manually trigger with custom settings" >> $GITHUB_STEP_SUMMARY |
| 181 | + else |
| 182 | + echo "🖱️ **Manual Trigger**: This was triggered manually from the Actions tab" >> $GITHUB_STEP_SUMMARY |
| 183 | + echo "⏰ **Auto-Schedule**: This workflow also runs automatically on schedule" >> $GITHUB_STEP_SUMMARY |
| 184 | + fi |
| 185 | +
|
| 186 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 187 | +
|
| 188 | + if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then |
| 189 | + echo "📋 **Dry Run**: No changes were made. Dashboard content was previewed only." >> $GITHUB_STEP_SUMMARY |
| 190 | + else |
| 191 | + echo "✅ **Dashboard Updated**: Check your repository issues for the updated dependency dashboard." >> $GITHUB_STEP_SUMMARY |
| 192 | + fi |
| 193 | +
|
| 194 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 195 | + echo "📊 View detailed logs above for dashboard update results." >> $GITHUB_STEP_SUMMARY |
0 commit comments