This bash script utilizes the GitHub CLI (gh) to gather statistics about GitHub Actions workflows in all repositories within a specified GitHub organization. It calculates the average time for the longest-running workflow and the average cost (consumed processing power) of workflows.
- Fetches statistics for GitHub Actions workflows in all repositories of a specified GitHub organization.
- Calculates the average time for the longest-running workflow.
- Calculates the average cost (consumed processing power) of workflows.
- Provides logging statements for better understanding and debugging.
- Github CLI
gh
installed and authenticated
- Copy the script content from github_actions_statistics.sh to a file named github_actions_statistics.sh.
- Make the script executable:
chmod +x github_actions_statistics.sh
- Optionally, move the script to a directory included in your $PATH to use it as a global command.
- Set your GitHub organization by modifying the ORG_NAME variable in the script:
ORG_NAME="your_organization"
- Run the script:
./github_actions_statistics.sh
- View the generated statistics, including the average time for the longest-running workflow and the average cost of workflows.
The script includes logging statements to provide information about the current stage of processing, including the repository and workflow being processed. This facilitates debugging and understanding the script's execution flow.
Fetching statistics for GitHub Actions workflows in organization: your_organization
Processing repository: repo1
Processing workflow: workflow1
...
(Output for each workflow run)
...
Processing workflow: workflow2
...
(Output for each workflow run)
...
Processing repository: repo2
Processing workflow: workflow3
...
(Output for each workflow run)
...
...
===========================
Summary for organization: your_organization
===========================
Average time for longest-running workflow: <average_time> minutes
Average cost of workflows: <average_cost> credits
- Ensure that the GitHub CLI (gh) is installed and authenticated.
- Customize the ORG_NAME variable in the script with your GitHub organization name.
This project is licensed under the MIT License - see the LICENSE file for details.