97 lines
4.0 KiB
YAML
97 lines
4.0 KiB
YAML
name: Weekly Metrics to Discord
|
|
# description: Sends weekly metrics summary to Discord channel
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 9 * * 1" # Every Monday at 9 AM
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
pull-requests: read
|
|
|
|
jobs:
|
|
weekly-metrics:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_METRICS_WEBHOOK }}
|
|
steps:
|
|
- name: Get dates for last week
|
|
run: |
|
|
# Last 7 days
|
|
first_day=$(date -d "7 days ago" +%Y-%m-%d)
|
|
last_day=$(date +%Y-%m-%d)
|
|
|
|
echo "first_day=$first_day" >> $GITHUB_ENV
|
|
echo "last_day=$last_day" >> $GITHUB_ENV
|
|
echo "week_of=$(date -d '7 days ago' +'Week of %B %d, %Y')" >> $GITHUB_ENV
|
|
|
|
- name: Generate issue metrics
|
|
uses: github/issue-metrics@v3
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SEARCH_QUERY: "repo:${{ github.repository }} is:issue created:${{ env.first_day }}..${{ env.last_day }}"
|
|
HIDE_TIME_TO_ANSWER: true
|
|
HIDE_LABEL_METRICS: false
|
|
|
|
- name: Generate PR metrics
|
|
uses: github/issue-metrics@v3
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SEARCH_QUERY: "repo:${{ github.repository }} is:pr created:${{ env.first_day }}..${{ env.last_day }}"
|
|
OUTPUT_FILE: pr_metrics.md
|
|
|
|
- name: Parse metrics
|
|
id: metrics
|
|
run: |
|
|
# Parse the metrics from the generated markdown files
|
|
if [ -f "issue_metrics.md" ]; then
|
|
# Extract key metrics using grep/awk
|
|
AVG_TIME_TO_FIRST_RESPONSE=$(grep -A 1 "Average time to first response" issue_metrics.md | tail -1 | xargs || echo "N/A")
|
|
AVG_TIME_TO_CLOSE=$(grep -A 1 "Average time to close" issue_metrics.md | tail -1 | xargs || echo "N/A")
|
|
NUM_ISSUES_CREATED=$(grep -oP '\d+(?= issues created)' issue_metrics.md || echo "0")
|
|
NUM_ISSUES_CLOSED=$(grep -oP '\d+(?= issues closed)' issue_metrics.md || echo "0")
|
|
fi
|
|
|
|
if [ -f "pr_metrics.md" ]; then
|
|
PR_AVG_TIME_TO_MERGE=$(grep -A 1 "Average time to close" pr_metrics.md | tail -1 | xargs || echo "N/A")
|
|
NUM_PRS_CREATED=$(grep -oP '\d+(?= pull requests created)' pr_metrics.md || echo "0")
|
|
NUM_PRS_MERGED=$(grep -oP '\d+(?= pull requests closed)' pr_metrics.md || echo "0")
|
|
fi
|
|
|
|
# Set outputs for Discord action
|
|
echo "issues_created=${NUM_ISSUES_CREATED:-0}" >> $GITHUB_OUTPUT
|
|
echo "issues_closed=${NUM_ISSUES_CLOSED:-0}" >> $GITHUB_OUTPUT
|
|
echo "prs_created=${NUM_PRS_CREATED:-0}" >> $GITHUB_OUTPUT
|
|
echo "prs_merged=${NUM_PRS_MERGED:-0}" >> $GITHUB_OUTPUT
|
|
echo "avg_first_response=${AVG_TIME_TO_FIRST_RESPONSE:-N/A}" >> $GITHUB_OUTPUT
|
|
echo "avg_time_to_close=${AVG_TIME_TO_CLOSE:-N/A}" >> $GITHUB_OUTPUT
|
|
echo "pr_avg_merge_time=${PR_AVG_TIME_TO_MERGE:-N/A}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Send to Discord
|
|
uses: sarisia/actions-status-discord@v1
|
|
if: env.DISCORD_WEBHOOK != ''
|
|
with:
|
|
webhook: ${{ env.DISCORD_WEBHOOK }}
|
|
status: Success
|
|
title: "📊 Weekly Metrics Report"
|
|
description: |
|
|
**${{ env.week_of }}**
|
|
|
|
**🎯 Issues**
|
|
• Created: ${{ steps.metrics.outputs.issues_created }}
|
|
• Closed: ${{ steps.metrics.outputs.issues_closed }}
|
|
|
|
**🔀 Pull Requests**
|
|
• Created: ${{ steps.metrics.outputs.prs_created }}
|
|
• Merged: ${{ steps.metrics.outputs.prs_merged }}
|
|
|
|
**⏱️ Response Times**
|
|
• First Response: ${{ steps.metrics.outputs.avg_first_response }}
|
|
• Time to Close: ${{ steps.metrics.outputs.avg_time_to_close }}
|
|
• PR Merge Time: ${{ steps.metrics.outputs.pr_avg_merge_time }}
|
|
color: 0x58AFFF
|
|
username: Task Master Metrics Bot
|
|
avatar_url: https://raw.githubusercontent.com/eyaltoledano/claude-task-master/main/images/logo.png
|