From f75c42332c44c0d2a1a7e7a7ea32c2ef346df609 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 10 May 2025 09:47:03 -0700 Subject: [PATCH 1/6] feat: :technologist: github workflow to measure issue/PR stats --- .github/workflows/metrics.yaml | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/metrics.yaml diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml new file mode 100644 index 000000000..0c0bbe423 --- /dev/null +++ b/.github/workflows/metrics.yaml @@ -0,0 +1,46 @@ +name: Monthly issue metrics +on: + workflow_dispatch: + schedule: + # Runs every Monday at 9:00 AM PST (17:00 UTC) + - cron: "0 17 * * 1" + + push: + branches: + - nate/metrics-action + +permissions: + contents: read + +jobs: + build: + name: issue metrics + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: read + steps: + - name: Get dates for last month + shell: bash + run: | + # Calculate the first day of the previous month + first_day=$(date -d "last month" +%Y-%m-01) + + # Calculate the last day of the previous month + last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) + + #Set an environment variable with the date range + echo "$first_day..$last_day" + echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" + + - name: Run issue-metrics tool + uses: github/issue-metrics@v3 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SEARCH_QUERY: 'repo:continuedev/continue created:${{ env.last_month }} -reason:"not planned"' + + - name: Upload metrics report as artifact + uses: actions/upload-artifact@v3 + with: + name: issue-metrics-report + path: ./issue_metrics.md From d24862a6fd22e4eac1b2ca27ce7bf029f0d8fa4a Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 10 May 2025 09:49:56 -0700 Subject: [PATCH 2/6] fix: :bookmark: v3 -> v4 of upload-artifact --- .github/workflows/metrics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index 0c0bbe423..41e3472ab 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -40,7 +40,7 @@ jobs: SEARCH_QUERY: 'repo:continuedev/continue created:${{ env.last_month }} -reason:"not planned"' - name: Upload metrics report as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: issue-metrics-report path: ./issue_metrics.md From ad3e2b4660e758e7e2b94603088e2f3e3ee9c135 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 10 May 2025 10:29:50 -0700 Subject: [PATCH 3/6] send to slack --- .github/workflows/metrics.yaml | 39 +++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index 41e3472ab..a84130a68 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -33,11 +33,40 @@ jobs: echo "$first_day..$last_day" echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" - - name: Run issue-metrics tool - uses: github/issue-metrics@v3 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SEARCH_QUERY: 'repo:continuedev/continue created:${{ env.last_month }} -reason:"not planned"' + # - name: Run issue-metrics tool + # uses: github/issue-metrics@v3 + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # SEARCH_QUERY: 'repo:continuedev/continue created:${{ env.last_month }} -reason:"not planned"' + + - name: Read metrics file content + id: read-metrics + run: | + content=$(echo "abc") + echo "metrics_content=$content" >> "$GITHUB_OUTPUT" + + # content=$(cat ./issue_metrics.md) + # # This prepares the content in a way that can be used in GitHub Actions + # content="${content//'%'/'%25'}" + # content="${content//$'\n'/'%0A'}" + # content="${content//$'\r'/'%0D'}" + - name: Post a message in a channel + uses: slackapi/slack-github-action@v2.1.0 + with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook-type: incoming-webhook + payload: | + text: "Issue / PR Metrics Report" + blocks: + - type: "header" + text: + type: "plain_text" + text: "Monthly Issue Metrics Report" + emoji: true + - type: "section" + text: + type: "mrkdwn" + text: "${{ steps.read-metrics.outputs.metrics_content }}" - name: Upload metrics report as artifact uses: actions/upload-artifact@v4 From cef59ec815e10d26930e1e81a12da44ec7224c34 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 10 May 2025 10:31:07 -0700 Subject: [PATCH 4/6] correct secret name --- .github/workflows/metrics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index a84130a68..dbfaea06b 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -53,7 +53,7 @@ jobs: - name: Post a message in a channel uses: slackapi/slack-github-action@v2.1.0 with: - webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook: ${{ secrets.ISSUE_PR_METRICS_SLACK_WEBHOOK_URL }} webhook-type: incoming-webhook payload: | text: "Issue / PR Metrics Report" From db0d00a439011fefacd59e1453b8fe4048773ab3 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 10 May 2025 10:33:02 -0700 Subject: [PATCH 5/6] add back metrics step --- .github/workflows/metrics.yaml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index dbfaea06b..c543d2967 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -33,23 +33,22 @@ jobs: echo "$first_day..$last_day" echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" - # - name: Run issue-metrics tool - # uses: github/issue-metrics@v3 - # env: - # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # SEARCH_QUERY: 'repo:continuedev/continue created:${{ env.last_month }} -reason:"not planned"' + - name: Run issue-metrics tool + uses: github/issue-metrics@v3 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SEARCH_QUERY: 'repo:continuedev/continue created:${{ env.last_month }} -reason:"not planned"' - name: Read metrics file content id: read-metrics run: | - content=$(echo "abc") + content=$(cat ./issue_metrics.md) + # This prepares the content in a way that can be used in GitHub Actions + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + # content="${content//$'\r'/'%0D'}" echo "metrics_content=$content" >> "$GITHUB_OUTPUT" - # content=$(cat ./issue_metrics.md) - # # This prepares the content in a way that can be used in GitHub Actions - # content="${content//'%'/'%25'}" - # content="${content//$'\n'/'%0A'}" - # content="${content//$'\r'/'%0D'}" - name: Post a message in a channel uses: slackapi/slack-github-action@v2.1.0 with: From 2b3db2322a804688007cff6632b7050c01a176df Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 10 May 2025 10:42:27 -0700 Subject: [PATCH 6/6] correctly format multi-line string in payload --- .github/workflows/metrics.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index c543d2967..1ee476aaf 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -65,7 +65,8 @@ jobs: - type: "section" text: type: "mrkdwn" - text: "${{ steps.read-metrics.outputs.metrics_content }}" + text: | + ${{ steps.read-metrics.outputs.metrics_content }} - name: Upload metrics report as artifact uses: actions/upload-artifact@v4