-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Changes from 5 commits
e770d03
e12bee9
fe9da9a
82eea8a
7630192
5d334a6
638d356
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
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 current day of the week (0=Sunday, 1=Monday, ..., 6=Saturday) | ||
CURRENT_DAY_OF_WEEK=$(date +%u) | ||
|
||
# Calculate the number of days to subtract to get to the previous Monday | ||
DAYS_TO_MONDAY=$((CURRENT_DAY_OF_WEEK - 1)) | ||
|
||
# Calculate the date of the previous Monday | ||
PREVIOUS_MONDAY=$(date -d "$DAYS_TO_MONDAY days ago" "+%Y-%m-%d") | ||
|
||
# Calculate the date of the current Sunday (assuming today is not Sunday) | ||
CURRENT_SUNDAY=$(date -d "$DAYS_TO_MONDAY days ago +6 day" "+%Y-%m-%d") | ||
|
||
# Set an environment variable with the date range | ||
echo "$PREVIOUS_MONDAY..$CURRENT_SUNDAY" | ||
echo "last_week=$PREVIOUS_MONDAY..$CURRENT_SUNDAY" >> "$GITHUB_ENV" | ||
|
||
- 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 |
||
with: | ||
title: Weekly PR metrics report | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
content-filepath: ./issue_metrics.md | ||
assignees: paulhcsun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may not work since the
DAYS_TO_MONDAY
will return0
if the script is running on monday.Moreover, since we already know the script will be executed only every monday based on the cron job scheduled, we can simplify as below to get last week (last monday to last sunday)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated