Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add weekly workflow for github issues/pr metrics #29444

Merged
merged 7 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/repo-metrics-weekly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Weekly repo metrics
on:
workflow_dispatch:
schedule:
- cron: '0 9 * * MON'

permissions:
issues: write
pull-requests: read

jobs:
build:
# this workflow will always fail in forks; bail if this isn't running in the upstream
if: github.repository == 'aws/aws-cdk'
name: metrics
runs-on: ubuntu-latest

steps:
- name: Get dates for last week
shell: bash
run: |
# Calculate the previous Monday's date
PREVIOUS_MONDAY=$(date -d "last monday" "+%Y-%m-%d")

# Calculate the current Sunday's date
CURRENT_SUNDAY=$(date -d "next Sunday" "+%Y-%m-%d")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: Just would like to know if "next sunday" provides the current sunday or the upcoming sunday? Since the script runs every monday, does this gives the current sunday? We could also get the current sunday may be using "yesterday"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point as this would be run every monday, I'll update the naming.


# Set an environment variable with the date range
echo "$PREVIOUS_MONDAY..$CURRENT_SUNDAY"
echo "last_week=$first_day..$last_day" >> "$GITHUB_ENV"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the variable needs to be updated with previous monday and current sunday

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!


- name: Report on issues
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:aws/aws-cdk is:issue created:${{ env.last_week }} -reason:"not planned"'

- name: Create report for issues
uses: peter-evans/create-issue-from-file@v5
with:
title: Weekly issue metrics report
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
assignees: paulhcsun

- name: Report on PRs
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:aws/aws-cdk is:pr created:${{ env.last_week }} -is:draft'

- name: Create report for PRs
uses: peter-evans/create-issue-from-file@v5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker. Would like to know is it normal and safe to use third party github actions for aws owned repos? As I can see this action is not from a Verified creator label which usually GITHUB does.

peter-evans/create-issue-from-file@v5 -> https://github.com/marketplace/actions/create-issue-from-file

Sample verified action: https://github.com/marketplace/actions/checkout
image

with:
title: Weekly PR metrics report
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
assignees: paulhcsun