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

Create issue metrics workflow #278

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

anupdsouza
Copy link
Contributor

What it Does

  • Closes Project Issue / PR Metrics #138
  • Created issue-metrics file that can be run manually to generate reports of issues and pr's that were opened and closed in the previous week. The workflow will need to be manually triggered, although this can be updated to run automatically as well via cron jobs.

How I Tested

  • Enabled the "Issues" tab for my personal repository and created a dummy issue for metric generation
  • Executed the issue-metrics workflow. The workflow generates reports as "Issues" which can then be viewed and action can be taken upon.

Notes

  • I've added a section in the workflow that generates dates for the previous month. It is commented out for now but it can be uncommented if one wishes to do a monthly report generation instead. The time calculations can be updated to suit one's needs.
  • I've also set the 'assignees' value to the repo owner, in this case its you @mikaelacaron. This allows the github bot to automatically assign the report issues to you.
  • I've also set the 'labels' value to 'weekly-report', this adds a nice little label against the issue.
  • Alternatively, you could just duplicate the workflow file and rename it to monthly-issue-metrics or something with the appropriate values. This way you could decide whether to run the weekly report or monthly report. This is up to your discretion.
  • To set up auto trigger via cron jobs, just add the following under workflow_dispatch:
Screenshot 2023-12-06 at 9 44 30 AM

Screenshots

Screenshot 2023-12-06 at 9 20 54 AM Screenshot 2023-12-06 at 9 20 44 AM Screenshot 2023-12-06 at 9 19 58 AM Screenshot 2023-12-06 at 9 19 44 AM Screenshot 2023-12-06 at 9 19 23 AM

Copy link
Owner

@mikaelacaron mikaelacaron left a comment

Choose a reason for hiding this comment

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

@anupdsouza I have a few questions just looking over the yml file, I haven't done this before, but just looking at the workflow you've written so far I wanted to clarify some of it, for my understanding

To set up auto trigger via cron jobs, just add the following under workflow_dispatch:

Is it possible for GitHub actions to trigger this, rather than it running as a cron job?

- name: Run issue-metrics tool for opened issues last week
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Owner

Choose a reason for hiding this comment

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

Do I need to do anything with this? Do I need to create some kind of secret for this to be able to create issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not required, as per Github documentation:

If you want the resulting issue with the metrics in it to appear in a different repository other than the one the workflow file runs in, update the line token: ${{ secrets.GITHUB_TOKEN }} with your own GitHub API token stored as a repository secret.

Comment on lines +34 to +42
# 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"
Copy link
Owner

Choose a reason for hiding this comment

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

Is this used for anything? It looks like it's all commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not used at the moment. I left it in as a reference if you wanted to update the workflow such that it'd fetch reports for the previous month instead of the previous week.

- name: Create issue for opened issues
uses: peter-evans/create-issue-from-file@v4
with:
title: ${{ env.prev_week }} opened issues
Copy link
Owner

Choose a reason for hiding this comment

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

Do I need an environment variable of some kind? This looks like it's referencing one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's defined on line 28.

@anupdsouza
Copy link
Contributor Author

@anupdsouza I have a few questions just looking over the yml file, I haven't done this before, but just looking at the workflow you've written so far I wanted to clarify some of it, for my understanding

To set up auto trigger via cron jobs, just add the following under workflow_dispatch:

Is it possible for GitHub actions to trigger this, rather than it running as a cron job?

As per Github documentation, the example uses cron job to schedule it to run once a month.

Wait for the action to trigger based on the schedule entry or manually trigger the workflow as shown in the documentation.

I suppose the workflow could be updated to run every time PR's are created or merged by doing something like this:

workflow_dispatch:
  pull_request:
    branches:
      - dev
  push:
    branches:
      - main
      - dev

but that would result in too many reports being generated. That's why I left it to be run manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project Issue / PR Metrics
2 participants