GitHub Action
GitHub Organization Code Frequency Report Action
A GitHub Action to generate a report that contains code frequency metrics and programming languages used per repository belonging to a GitHub organization.
The example workflow below runs on a monthly schedule using the amount of weeks as an interval set in action.yml
(default 4 weeks) and can also be triggered manually using a workflow_dispatch event.
name: Code Frequency Action
on:
schedule:
# Runs on the first day of the month at 00:00 UTC
#
# ┌────────────── minute
# │ ┌──────────── hour
# │ │ ┌────────── day (month)
# │ │ │ ┌──────── month
# │ │ │ │ ┌────── day (week)
- cron: '0 0 1 * *'
workflow_dispatch:
inputs:
fromdate:
description: 'Optional interval start date (format: yyyy-mm-dd)'
required: false # Skipped if workflow dispatch input is not provided
todate:
description: 'Optional interval end date (format: yyyy-mm-dd)'
required: false # Skipped if workflow dispatch input is not provided
jobs:
code-frequency-report:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get Git audit-log
uses: nicklegan/github-org-code-frequency-action@v1.0.1
with:
token: ${{ secrets.ORG_TOKEN }}
fromdate: ${{ github.event.inputs.fromdate }} # Used for workflow dispatch input
todate: ${{ github.event.inputs.todate }} # Used for workflow dispatch input
Name | Value | Required |
---|---|---|
ORG_TOKEN |
A repo , read:org scoped Personal Access Token |
true |
ACTIONS_STEP_DEBUG |
true Enables diagnostic logging |
false |
💡 Disable token expiration to avoid failed workflow runs when running on a schedule.
Name | Description | Default | Options | Required |
---|---|---|---|---|
org |
Organization different than workflow context | false |
||
weeks |
Amount of weeks in the past to collect data for (weeks start on Sunday 00:00:00 GMT) | 4 |
false |
|
sort |
Column used to sort the acquired code frequency data | additions |
additions, deletions, alltimeAdditions, alltimeDeletions, primaryLanguage, createdDate |
false |
committer-name |
The name of the committer that will appear in the Git history | github-actions |
false |
|
committer-email |
The committer email that will appear in the Git history | github-actions@github.com |
false |
The additional option to retrieve code frequency data using a custom date interval.
If the below fields are left empty during workflow dispatch input, the default interval option of set weeks from the current date configured in main.yml
will be used instead.
💡 The result data includes the weeks which have their start date (Sunday 00:00:00 GMT) within the set interval.
Name | Value | Required |
---|---|---|
Optional interval start date |
A date matching the format yyyy-mm-dd |
false |
Optional interval end date |
A date matching the format yyyy-mm-dd |
false |
The results of the 2nd and 3rd report column will be the sum of code frequency date for the selected interval per organization repository.
Column | Description |
---|---|
Repository | Organization owned repository |
Lines added (interval) | Number of lines of code added during set interval |
Lines deleted (interval) | Number of lines of code deleted during set interval |
All time lines added | Number of lines of code added since repo creation |
All time lines deleted | Number of lines of code deleted since repo creation |
Primary language | The primary programming language used in the repo |
All languages | All programming languages used in the repo |
Repo creation date | Date the repo has been created |
A CSV report file to be saved in the repository reports
folder using the following naming format: organization-date-interval.csv
.
In some scenarios it might be preferred to authenthicate as a GitHub App rather than using a personal access token.
The following features could be a benefit authenticating as a GitHub App installation:
- The GitHub App is directly installed on the organization, no separate user account is required.
- A GitHub App has more granular permissions than a personal access token.
- To avoid hitting the 5000 requests per hour GitHub API rate limit, authenticating as a GitHub App installation would increase the API request limit.
The GitHub App authentication strategy can be integrated with the Octokit library by installing and configuring the @octokit/auth-app npm module before rebuilding the Action in a separate repository.