chore: add weekly workflow for github issues/pr metrics#29444
chore: add weekly workflow for github issues/pr metrics#29444mergify[bot] merged 7 commits intoaws:mainfrom
Conversation
|
|
||
| # Set an environment variable with the date range | ||
| echo "$PREVIOUS_MONDAY..$CURRENT_SUNDAY" | ||
| echo "last_week=$first_day..$last_day" >> "$GITHUB_ENV" |
There was a problem hiding this comment.
Seems the variable needs to be updated with previous monday and current sunday
| PREVIOUS_MONDAY=$(date -d "last monday" "+%Y-%m-%d") | ||
|
|
||
| # Calculate the current Sunday's date | ||
| CURRENT_SUNDAY=$(date -d "next Sunday" "+%Y-%m-%d") |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
Good point as this would be run every monday, I'll update the naming.
godwingrs22
left a comment
There was a problem hiding this comment.
Overall looks good. Just few minor comments.
| PREVIOUS_MONDAY=$(date -d "last monday" "+%Y-%m-%d") | ||
|
|
||
| # Calculate the current Sunday's date | ||
| CURRENT_SUNDAY=$(date -d "current Sunday" "+%Y-%m-%d") |
There was a problem hiding this comment.
Just wondering if this command returns the correct previous monday and current sunday? Because to me seems both identical +%Y-%m-%d. Do you have any reference doc or any sample?
There was a problem hiding this comment.
nit: consider renaming last monday to previous monday or vice versa to be consistent.
There was a problem hiding this comment.
Oh wait you're right that's not actually doing anything right now, let me have a look
There was a problem hiding this comment.
Pushed updated shell script. Here's some docs to reference: https://ioflood.com/blog/bash-date-format/
| 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") |
There was a problem hiding this comment.
I think this may not work since the DAYS_TO_MONDAY will return 0 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)
LAST_MONDAY=$(date -d "7 days ago" "+%Y-%m-%d")
LAST_SUNDAY=$(date -d "1 day ago" "+%Y-%m-%d")
godwingrs22
left a comment
There was a problem hiding this comment.
LGTM. Left a comment
| 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.
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

|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Issue # (if applicable)
Closes #.
Reason for this change
Generate weekly version of the PR/issues metrics.
Description of changes
Add new workflow that runs weekly on Mondays @ 9 AM to generate a PR/Issue metrics report for the past week (Monday - Sunday).
Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license