{"id":20880201,"url":"https://github.com/kittychiu/workflow-metrics","last_synced_at":"2025-07-05T10:39:05.913Z","repository":{"id":187805407,"uuid":"677596241","full_name":"KittyChiu/workflow-metrics","owner":"KittyChiu","description":"A GitHub action to measure GitHub Actions workflow metrics. An enabler to put the concept discussed in the post to practice - https://www.kittychiu.com/posts/managing-actions-consumption/.","archived":false,"fork":false,"pushed_at":"2024-01-16T16:03:55.000Z","size":74,"stargazers_count":23,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-17T09:01:53.056Z","etag":null,"topics":["action","github","marketplace"],"latest_commit_sha":null,"homepage":"https://github.com/KittyChiu/workflow-metrics","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KittyChiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-12T02:26:28.000Z","updated_at":"2025-03-08T11:50:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"ad6cb5ee-e1d2-4dfa-8d8a-7ad43a8d9a2b","html_url":"https://github.com/KittyChiu/workflow-metrics","commit_stats":null,"previous_names":["kittychiu/workflow-metrics"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyChiu%2Fworkflow-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyChiu%2Fworkflow-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyChiu%2Fworkflow-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyChiu%2Fworkflow-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KittyChiu","download_url":"https://codeload.github.com/KittyChiu/workflow-metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253776954,"owners_count":21962601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["action","github","marketplace"],"created_at":"2024-11-18T07:19:24.940Z","updated_at":"2025-05-12T16:32:09.004Z","avatar_url":"https://github.com/KittyChiu.png","language":"Python","readme":"# Workflow Metrics Action\n\n[![CodeQL](https://github.com/KittyChiu/workflow-metrics/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/KittyChiu/workflow-metrics/actions/workflows/github-code-scanning/codeql) [![Docker Image CI](https://github.com/KittyChiu/workflow-metrics/actions/workflows/docker-image.yml/badge.svg)](https://github.com/KittyChiu/workflow-metrics/actions/workflows/docker-image.yml)\n\nThis GitHub Action provides a way to evaluate statistics for your GitHub Actions workflows. With this action, you can easily monitor the performance of your workflows and identify areas for improvement.\n\nMetrics that are evaluated are:\n\n| Metric | Unit of measure | Description |\n| --- | --- | --- |\n| Average duration | second | Average of the successful workflow runs, with conclusion status of either `successful` or `skipped`. |\n| Median duration | second | Median of the successful workflow runs, with conclusion status of either `successful` or `skipped`. |\n| Total number of runs | workflow run | Total number of workflow runs. |\n| Success rate | percentage | Percentage of successful runs for the workflow, with conclusion status of either `successful` or `skipped`. |\n\n## Example use cases\n\n- As a product engineer, I want to identify areas of improvement for my process automation, so that I can improve delivery in next iteration.\n- As an engineering manager, I want to identify waste and inefficiencies in my SDLC process, so that I can reduce cycle time and improve velocity.\n- As a DevOps platform owner, I want to identify long running workflows, so that I can right-sizing the runners.\n\n## Configurations\n\nThe following options are available for configuring the action:\n\n| Configuration | Required | Default | Description |\n| --- | --- | --- | --- |\n| `GH_TOKEN` | Yes | N/A | A GitHub token with access to the repository. Minimal scope is `repo` |\n| `OWNER_NAME` | Yes | N/A | Name of the repository owner. |\n| `REPO_NAME` | No | N/A | Name of the repository. If `REPO_NAME` is not provided, the action will analyse all the workflow runs in the organisation. |\n| `START_DATE` | Yes | N/A | Start date for the workflow runs data set. This should be in the format `YYYY-MM-DD`. |\n| `END_DATE` | Yes | N/A | End date for the workflow runs data set. This should be in the format `YYYY-MM-DD`. |\n| `DELAY_BETWEEN_QUERY` | No | N/A | No. of seconds to wait between queries to the GitHub API. This is to prevent errors from rate limiting when analysing the whole org. |\n| `workflow-names.txt` | No | N/A | A file that contains a list of selected workflow names to filter the result. This should be in the runner's workspace folder. |\n\n## Outputs\n\nAfter the action has completed, two files will be created in the root of the runner workspace:\n\n- `runs.json` or `org-runs.json` - a JSON array of all workflow runs in the specified time range for the specified repository or organization.\n- `workflow-stats.csv` or `org-workflow-stats.csv` - a CSV file with workflow run statistics for the specified repository or organization.\n\nThese are data files that then can be used for further analysis or reporting in visualizer of your choice. For example, you can ingest into datastore and visualize with PowerBI. Below are some examples on generating markdown table and mermaid diagram with the data files\n\n## Example usages\n\nTo use this action, simply include it in your workflow file:\n\n### 1. Basic usage\n\nThis will analyse workflow runs in the selected repository, including the durations and success rate of each workflow.\n\n\u003cdetails\u003e\n\n```yml\nname: My Workflow\non: workflow_dispatch\njobs:\n  evaluate-actions-consumption:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Call workflow-runs action\n        uses: kittychiu/workflow-metrics@v0.4.7\n        env:\n          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          OWNER_NAME: \"myOrg\"\n          REPO_NAME: \"myRepo\"\n          START_DATE: \"2023-07-01\"\n          END_DATE: \"2023-08-01\"\n\n      - name: Upload all .txt .csv .md files to artifact\n        uses: actions/upload-artifact@v3\n        with:\n          name: workflow-stats\n          path: |\n            workflow-stats.csv\n            runs.json\n```\n\nBelow is an example of the `workflow-stats.csv` file:\n\n```csv\nworkflow_name,average_duration,median_duration,success_rate,total_runs\nworkflow_1,12.33,12.00,100.00,3\nworkflow_3,25.12,22.00,20.93,43\nworkflow_2,15.50,15.50,50.00,2\n```\n\n\u003c/details\u003e\n\n### 2. Weekly report on selected repository and post to a GitHub Issue\n\nThis will further convert `workflow-stats.csv` file containing workflow metrics into a markdown table, mermaid diagram, and publishes it to a new issue. An example of the rendered outputs is [in this Issue](https://github.com/KittyChiu/workflow-metrics/issues/17).\n\n\u003cdetails\u003e\n\n```yml\nname: Weekly Retrospective Report\n\non: \n  schedule:\n    - cron: '0 12 * * 5'\n    \njobs:\n  evaluate-actions-consumption:\n    runs-on: ubuntu-latest\n    env:\n      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n      OWNER_NAME: ${{ github.repository_owner }}\n\n    steps:\n      - name: Checkout workflow-names.txt\n        uses: actions/checkout@v3\n\n      - name: Set dates and repo name\n        run: |\n          echo \"START_DATE=$(date -d '-1 month' +%Y-%m-%d)\" \u003e\u003e \"$GITHUB_ENV\"\n          echo \"END_DATE=$(date +%Y-%m-%d)\" \u003e\u003e \"$GITHUB_ENV\"\n          \n          repo=$(echo \"${{ github.repository }}\" | cut -d'/' -f2)\n          echo \"REPO_NAME=${repo}\" \u003e\u003e $GITHUB_ENV\n\n      - name: Call workflow-runs action\n        uses: kittychiu/workflow-metrics@v0.4.7\n        env:\n          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          REPO_NAME: ${{ env.REPO_NAME }}\n          START_DATE: ${{ env.START_DATE }}\n          END_DATE: ${{ env.END_DATE }}\n\n      - name: Convert workflow-stats.CSV to stats-table.md markdown table\n        run: |\n          echo -e \"## Table View\\n\" \u003e stats-table.md\n          header=$(head -n 1 workflow-stats.csv | sed 's/,/|/g' | sed 's/_/ /g')\n          echo -e \"|${header}|\" \u003e\u003e stats-table.md\n          metadata=$(head -n 1 workflow-stats.csv | sed 's/,/|/g' | sed 's/[^|]/-/g')\n          echo -e \"|${metadata}|\" \u003e\u003e stats-table.md\n          tail -n +2 workflow-stats.csv | sed 's/,/|/g; s/^/|/; s/$/|/' \u003e\u003e stats-table.md\n\n      - name: Convert workflow-stats.CSV to stream-diagram.md mermaid diagram\n        run: |\n          echo -e \"## Value Stream View\\n\" \u003e stream-diagram.md\n          echo -e '```mermaid' \u003e\u003e stream-diagram.md\n          echo -e 'timeline' \u003e\u003e stream-diagram.md\n          head -n 1 workflow-stats.csv | sed 's/,/ : /g' | sed 's/_/ /g' | awk -F'|' '{for(i=1;i\u003c=NF;i++) printf(\"%s%s\", \"    \", $i, i==NF?\"\\n\":\", \")}' | sed 's/^/  /' \u003e\u003e stream-diagram.md\n          tail -n +2 workflow-stats.csv | sed 's/,/ : /g' | awk -F'|' '{for(i=1;i\u003c=NF;i++) printf(\"%s%s\", \"\\n    \", $i, i==NF?\"\\n\":\", \")}' | sed 's/^/  /' \u003e\u003e stream-diagram.md\n          echo -e '\\n```' \u003e\u003e stream-diagram.md\n\n      - name: Combine into issue content\n        run: |\n          echo \"Combine output files\"\n          cat stream-diagram.md stats-table.md \u003e issue_view.md\n\n      - name: Publish content to a new GitHub Issue\n        uses: peter-evans/create-issue-from-file@v4\n        with:\n          title: Workflow runs summary `${{ env.REPO_NAME }}` repo (${{ env.START_DATE }} - ${{ env.END_DATE }})\n          content-filepath: issue_view.md\n\n      - name: Upload all .txt .csv .md files to artifact\n        uses: actions/upload-artifact@v3\n        with:\n          name: workflow-stats\n          path: |\n            stats-table.md\n            stream-diagram.md\n            workflow-stats.csv\n            runs.json\n```\n\nExample content of `workflow-names.txt`:\n\n```\nworkflow_1\nworkflow_2\nworkflow_3\n```\n\nBelow is an example of the `stats-table.md` file:\n\n```md\n|workflow name|average duration|median duration|success rate|total runs|\n|-------------|----------------|---------------|------------|----------|\n|workflow_1|17.00|17.00|100.00|1|\n|workflow_2|36.17|36.50|53.70|54|\n|workflow_3|3.00|2.00|100.00|3|\n```\n\nBelow is an example of the `stream-diagram.md` file:\n\n```mermaid\ntimeline\n      workflow name : average duration : median duration : success rate : total runs  \n      CI Build : 17.00 : 17.00 : 100.00 : 1\n      QA \u0026 Validation : 36.17 : 36.50 : 53.70 : 54\n      Deploy to non-prod : 3.00 : 2.00 : 100.00 : 3\n```\n\n\u003c/details\u003e\n\n### 3. Monthly report for the whole org and post to a GitHub Issue\n\nThis will analyse workflow runs in the selected organisation, including all workflows for each repository. An example of the rendered output is [in this Issue](https://github.com/KittyChiu/workflow-metrics/issues/18).\n\n\n\n\u003cdetails\u003e\n\n```yml\nname: Monthly SLOs Report\n\non:\n  schedule:\n    - cron: '0 0 1 * *'\n\njobs:\n  evaluate-actions-consumption:\n    runs-on: ubuntu-latest\n    env:\n      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n    steps:\n      - name: Set dates\n        run: |\n          echo \"START_DATE=$(date -d '-14 days' +%Y-%m-%d)\" \u003e\u003e \"$GITHUB_ENV\"\n          echo \"END_DATE=$(date +%Y-%m-%d)\" \u003e\u003e \"$GITHUB_ENV\"\n          \n      - name: Test docker action\n        uses: kittychiu/workflow-metrics@v0.4.7\n        env:\n          GH_TOKEN: ${{ env.GH_TOKEN }}\n          OWNER_NAME: ${{ github.repository_owner }}\n          START_DATE: ${{ env.START_DATE }}\n          END_DATE: ${{ env.END_DATE }}\n          DELAY_BETWEEN_QUERY: 5\n    \n      - name: Convert org-workflow-stats.csv to stats-table.md markdown table\n        run: |\n          echo -e \"## Table View\\n\" \u003e stats-table.md\n          header=$(head -n 1 org-workflow-stats.csv | sed 's/,/|/g' | sed 's/_/ /g')\n          echo -e \"|${header}|\" \u003e\u003e stats-table.md\n          metadata=$(head -n 1 org-workflow-stats.csv | sed 's/,/|/g' | sed 's/[^|]/-/g')\n          echo -e \"|${metadata}|\" \u003e\u003e stats-table.md\n          tail -n +2 org-workflow-stats.csv | sed 's/,/|/g; s/^/|/; s/$/|/' \u003e\u003e stats-table.md\n\n      - name: Publish result to a new issue\n        uses: peter-evans/create-issue-from-file@v4\n        with:\n          title: Workflow runs summary for `${{ env.OWNER_NAME }}` org (${{ env.START_DATE }} - ${{ env.END_DATE }})\n          content-filepath: stats-table.md\n\n      - name: Upload all .txt .csv .md files to artifact\n        uses: actions/upload-artifact@v3\n        with:\n          name: workflow-stats\n          path: |\n            stats-table.md\n            org-workflow-stats.csv\n            org-runs.json\n```\n\nBelow is an example of the `stats-table.md` file:\n\n```md\n|repository name|workflow name|average duration|median duration|success rate|total runs|\n|---------------|-------------|----------------|---------------|------------|----------|\n|repo_1|Test|3.00|3.00|100.00|1|\n|repo_1|Build|20.20|17.00|80.00|5|\n|repo_1|Deploy|17.00|17.00|100.00|1|\n|repo_2|Custom Validation|2.00|2.00|100.00|1|\n|repo_2|Linter|2.00|2.00|100.00|1|\n|repo_3|Superlinter|25.38|23.00|30.00|50|\n|repo_3|Long Build|36.17|36.50|53.70|54|\n|repo_3|Smoke Test|19.69|14.00|23.08|13|\n```\n\n\u003c/details\u003e\n\n## Contributing\n\nPlease see the [contributing guidelines](CONTRIBUTING.md) for more information.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkittychiu%2Fworkflow-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkittychiu%2Fworkflow-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkittychiu%2Fworkflow-metrics/lists"}