English | 日本語
A GitHub Actions for collecting system metrics during workflows and outputting Mermaid charts.
- System Metrics Collection: Collects CPU load and memory usage in real-time during workflow execution
- Mermaid Chart Generation: Visualizes collected metrics as Mermaid stacked bar charts
- Job Summary Output: Automatically displays charts in GitHub Actions job summary
The following charts and data are output.
Stacked bar chart of system/user CPU load.
Stacked bar chart of active/available memory.
JSON data of CPU Loads and Memory Usages.
This action is designed to be executed at the beginning of a workflow.
name: Example Workflow
on: [push]
jobs:
example:
runs-on: ubuntu-latest
steps:
# Run actions-workflow-metrics at the beginning of the workflow
- name: Start Workflow Telemetry
uses: dev-hato/actions-workflow-metrics@v1
# Subsequent regular steps
- name: Checkout
uses: actions/checkout@v4
- name: Run tests
run: npm test
# ... other steps- main (workflow start): Starts metrics collection server in the background
- Workflow steps: Execute normally while metrics are collected in the background
- post (workflow end): Renders collected metrics as Mermaid charts and outputs to job summary
- Node.js: 24.x
- TypeScript: 5
- Package Manager: Bun
- Key Libraries:
systeminformation: System metrics collectionzod: Schema validation@actions/core: GitHub Actions integration
bun installFor security, install pre-commit. It automatically checks for credentials on commit.
# macOS
brew install pre-commit
# or using pip
pip install pre-commit
# Install pre-commit hooks
pre-commit installThis automatically runs gitleaks on commit. It checks for sensitive information like API keys or tokens.
# Type check + bundle (outputs to dist/ directory)
bun run build
# Run unit tests (Bun test runner)
bun test
# Code formatting (Prettier)
bun run fixsrc/
├── lib.ts # Common schema and server settings
├── main/
│ ├── index.ts # main entry point (server startup)
│ ├── server.ts # Metrics collection HTTP server
│ ├── metrics.ts # Metrics class (metrics management)
│ └── metrics.test.ts # Metrics class tests
└── post/
├── index.ts # post entry point (job summary output)
├── lib.ts # Metrics fetch and rendering
├── lib.test.ts # Rendering logic tests
├── renderer.ts # Mermaid chart generation
└── renderer.test.ts # Mermaid chart generation tests
src/main/index.tsis executed- Node.js spawns
src/main/server.tsas a detached process - Server starts serving metrics JSON at
localhost:7777 Metricsclass collects CPU/memory information every 5 seconds usingsysteminformationlibrary
src/post/index.tsis executed- Fetches metrics JSON from
localhost:7777(timeout: 10 seconds) Rendererclass generates Mermaid charts- Outputs to job summary using
@actions/coresummaryAPI


