Changesets · Branches · Tags · Compare
| Changeset | fa514d4463b9a7b065ff41c839da5504120838419d4194b5d0fe40ef0dffd1da |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-05-25 21:45 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-05-25 21:45 -07:00 |
| Parents | 419651c68e24, ef601eb11092 |
1 file changed
added .github/workflows/metrics.yaml +75 −0
| @@ -0,0 +1,75 @@ | ||
| 1 | +name: Monthly issue metrics | |
| 2 | +on: | |
| 3 | + workflow_dispatch: | |
| 4 | + schedule: | |
| 5 | + # Runs every Monday at 9:00 AM PST (17:00 UTC) | |
| 6 | + - cron: "0 17 * * 1" | |
| 7 | + | |
| 8 | + push: | |
| 9 | + branches: | |
| 10 | + - nate/metrics-action | |
| 11 | + | |
| 12 | +permissions: | |
| 13 | + contents: read | |
| 14 | + | |
| 15 | +jobs: | |
| 16 | + build: | |
| 17 | + name: issue metrics | |
| 18 | + runs-on: ubuntu-latest | |
| 19 | + permissions: | |
| 20 | + issues: write | |
| 21 | + pull-requests: read | |
| 22 | + steps: | |
| 23 | + - name: Get dates for last month | |
| 24 | + shell: bash | |
| 25 | + run: | | |
| 26 | + # Calculate the first day of the previous month | |
| 27 | + first_day=$(date -d "last month" +%Y-%m-01) | |
| 28 | + | |
| 29 | + # Calculate the last day of the previous month | |
| 30 | + last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) | |
| 31 | + | |
| 32 | + #Set an environment variable with the date range | |
| 33 | + echo "$first_day..$last_day" | |
| 34 | + echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" | |
| 35 | + | |
| 36 | + - name: Run issue-metrics tool | |
| 37 | + uses: github/issue-metrics@v3 | |
| 38 | + env: | |
| 39 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| 40 | + SEARCH_QUERY: 'repo:continuedev/continue created:${{ env.last_month }} -reason:"not planned"' | |
| 41 | + | |
| 42 | + - name: Read metrics file content | |
| 43 | + id: read-metrics | |
| 44 | + run: | | |
| 45 | + content=$(cat ./issue_metrics.md) | |
| 46 | + # This prepares the content in a way that can be used in GitHub Actions | |
| 47 | + content="${content//'%'/'%25'}" | |
| 48 | + content="${content//$'\n'/'%0A'}" | |
| 49 | + # content="${content//$'\r'/'%0D'}" | |
| 50 | + echo "metrics_content=$content" >> "$GITHUB_OUTPUT" | |
| 51 | + | |
| 52 | + - name: Post a message in a channel | |
| 53 | + uses: slackapi/slack-github-action@v2.1.0 | |
| 54 | + with: | |
| 55 | + webhook: ${{ secrets.ISSUE_PR_METRICS_SLACK_WEBHOOK_URL }} | |
| 56 | + webhook-type: incoming-webhook | |
| 57 | + payload: | | |
| 58 | + text: "Issue / PR Metrics Report" | |
| 59 | + blocks: | |
| 60 | + - type: "header" | |
| 61 | + text: | |
| 62 | + type: "plain_text" | |
| 63 | + text: "Monthly Issue Metrics Report" | |
| 64 | + emoji: true | |
| 65 | + - type: "section" | |
| 66 | + text: | |
| 67 | + type: "mrkdwn" | |
| 68 | + text: | | |
| 69 | + ${{ steps.read-metrics.outputs.metrics_content }} | |
| 70 | + | |
| 71 | + - name: Upload metrics report as artifact | |
| 72 | + uses: actions/upload-artifact@v4 | |
| 73 | + with: | |
| 74 | + name: issue-metrics-report | |
| 75 | + path: ./issue_metrics.md |