This repository contains a reusable GitHub composite action for running the git-hours tool.
The action lives at .github/actions/git-hours and performs the following:
- Installs Go and the
git-hourstool from thecmd/git-hourspackage. - Runs
git-hourswith optionalwindow_startandrepo_pathinputs. - Converts the output to
git-hours.json. - Exposes the generated file path as the
resultsoutput.
Create .github/workflows/coding-hours-report.yml:
name: Coding Hours Report
on:
workflow_dispatch:
inputs:
window_start:
description: 'Start date for git-hours (YYYY-MM-DD)'
required: false
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: ./.github/actions/git-hours
id: hours
with:
window_start: ${{ github.event.inputs.window_start }}
repo_path: '.'
- uses: actions/upload-artifact@v4
with:
name: git-hours
path: ${{ steps.hours.outputs.results }}Run the workflow manually and the resulting git-hours.json file will be available as an artifact.
A separate workflow, .github/workflows/org-coding-hours.yml, reads a list of repositories from docs/repos.json and generates coding hours reports for each one. Each repository is checked out under a repo directory and that path is passed to the repo_path input of the action. The reports can be published or downloaded as artifacts. The repository also serves a GitHub Pages site under the docs folder that lists the repositories being tracked. You can view docs/index.html on GitHub Pages to see the current list.
The default docs/repos.json file includes open source repositories such as ni/labview-icon-editor, ni/actor-framework, and ni/open-source. You can modify this file to track additional projects. Running the workflow will generate a git-hours.json report for each repository, which can be used to recognize the contributions of collaborators.