|
1 | 1 | name: Monthly Repository Statistics |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - types: [opened, synchronize] |
6 | | - schedule: |
7 | | - - cron: "0 9 1 * *" |
8 | 4 | workflow_dispatch: |
9 | 5 |
|
10 | 6 | jobs: |
|
20 | 16 |
|
21 | 17 | - name: Generate Enhanced Monthly Statistics |
22 | 18 | uses: actions/github-script@v7 |
23 | | - env: |
24 | | - MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} |
25 | 19 | with: |
26 | 20 | script: | |
27 | 21 | // Enhanced stats with additional metrics - main branch focused |
@@ -361,8 +355,7 @@ jobs: |
361 | 355 | }); |
362 | 356 | |
363 | 357 | // Create new branch |
364 | | - const now = new Date(); |
365 | | - const branchName = `update-stats-${now.getFullYear()}-${(now.getMonth()).toString().padStart(2, '0')}`; |
| 358 | + const branchName = 'monthly-stats'; |
366 | 359 | |
367 | 360 | try { |
368 | 361 | const mainRef = await github.rest.git.getRef({ |
@@ -465,48 +458,12 @@ jobs: |
465 | 458 | |
466 | 459 | const latest = monthlyData[monthlyData.length - 1]; |
467 | 460 | |
468 | | - const mattermostPayload = { |
469 | | - text: `📊 **${latest.month} Repository Activity Report**`, |
470 | | - attachments: [{ |
471 | | - color: '#22c55e', |
472 | | - fields: [ |
473 | | - // Core Development Activity |
474 | | - { title: '📝 Total Commits', value: latest.stats.totalCommits.toString(), short: true }, |
475 | | - { title: '👥 Active Contributors', value: latest.stats.activeContributors.toString(), short: true }, |
476 | | - { title: '📈 Lines Added', value: latest.stats.linesAdded.toLocaleString(), short: true }, |
477 | | - { title: '📉 Lines Deleted', value: latest.stats.linesDeleted.toLocaleString(), short: true }, |
478 | | - { title: '⚖️ Total Lines Changed', value: latest.stats.totalLinesChanged.toLocaleString(), short: true }, |
479 | | - { title: '📁 Files Changed', value: latest.stats.filesChanged.toString(), short: true }, |
480 | | - |
481 | | - // Pull Request Activity |
482 | | - { title: '🔀 PRs Merged', value: latest.prStats.merged.toString(), short: true }, |
483 | | - { title: '🆕 PRs Opened', value: latest.prStats.opened.toString(), short: true }, |
484 | | - { title: '❌ PRs Closed', value: latest.prStats.closed.toString(), short: true }, |
485 | | - |
486 | | - // Issue Management |
487 | | - { title: '🐛 Issues Opened', value: latest.issueStats.opened.toString(), short: true }, |
488 | | - { title: '✅ Issues Closed', value: latest.issueStats.closed.toString(), short: true }, |
489 | | - ], |
490 | | - text: `**👥 Active Contributors:** ${latest.stats.contributorsList.slice(0, 15).join(', ') || 'None'}\n` + |
491 | | - `**💻 Languages:** ${languages.map(l => `${l.language} (${l.percentage}%)`).join(', ') || 'N/A'}\n\n` + |
492 | | - `**📈 Charts:** [View detailed charts on branch ${branchResult.branchName}](${branchResult.branchUrl})\n` + |
493 | | - `**📊 CSV Report:** [Download CSV file](${branchResult.csvUrl})\n` + |
494 | | - `**🦠 Repository:** ${context.repo.owner}/${context.repo.repo}`, |
495 | | - footer: 'Repository statistics • Generated by GitHub Actions' |
496 | | - }] |
497 | | - }; |
498 | | -
|
499 | | - const response = await fetch(process.env.MATTERMOST_WEBHOOK_URL, { |
500 | | - method: 'POST', |
501 | | - headers: { 'Content-Type': 'application/json' }, |
502 | | - body: JSON.stringify(mattermostPayload) |
503 | | - }); |
504 | | -
|
505 | | - if (!response.ok) { |
506 | | - throw new Error(`Mattermost webhook failed: ${response.status}`); |
507 | | - } |
508 | | -
|
509 | 461 | console.log('Monthly report completed successfully'); |
| 462 | + console.log(`Branch: ${branchResult.branchName}`); |
| 463 | + console.log(`Branch URL: ${branchResult.branchUrl}`); |
| 464 | + console.log(`CSV URL: ${branchResult.csvUrl}`); |
| 465 | + console.log(`CSV Filename: ${branchResult.csvFileName}`); |
| 466 | + console.log(`Contributors: ${latest.stats.contributorsList.join(', ')}`); |
510 | 467 | console.log(`Generated stats for ${latest.month}:`); |
511 | 468 | console.log(`- Commits: ${latest.stats.totalCommits}`); |
512 | 469 | console.log(`- Contributors: ${latest.stats.activeContributors}`); |
|
0 commit comments