d-flows
π Project Summary
d-flows is a collection of reusable GitHub Actions workflows designed to streamline CI/CD across multiple repositories.
βοΈ What d-flows does
step-summary.ymlβ Sets GitHub Actions step summaries with custom Markdown. Supports appending or overwriting, with optional titles.discord-notify.ymlβ Sends Discord notifications via webhooks. Supports simple messages and rich embeds (optional fields, colors, JSON field arrays).
In addition, d-flows implements a semantic versioning and release system via two coordinated workflows:
bump-version.ymlβ Calculates version numbers and triggers releases.release.ymlβ Creates GitHub releases and manages version tags.
π§© Technical challenges
1) Reusable workflow design
- Flexible but easy-to-consume inputs for both simple and advanced use cases.
- Embed support in
discord-notify.ymlwith optional fields and color theming. - Summary handling in
step-summary.ymlwith append/overwrite modes.
2) Semantic versioning automation
- Branch-based constraints:
maintracks the latest major;release/vXmaintains older majors. - First release validation: ensure first releases originate from
main. - Major tag management: keep lightweight tags (
v1,v2, β¦) pointing to the latest patch within a major. - Correctly bump major/minor/patch depending on branch and state.
3) Cross-repository usage tracking
- Accurately count invocations via the Actions API with
event=workflow_call. - Implement retry and rate limit handling for reliability.
- Maintain a historical CSV on the
outputbranch and compute daily deltas.
π Dynamic counter: usage tracking via nntin/me repo
How gen_workflow_usage.ps1 works
The script tracks usage of the reusable workflows through a simple pipeline:
- API query: ask the
d-flowsrepo for workflow runs filtered byevent=workflow_call(thetotal_countgives cumulative invocations). - Historical state: fetch the previous CSV directly from the
outputbranch usinggit show output:workflow-usage.csv(with a precedinggit fetch origin output:output). - Delta calculation: compute daily increments from the last known totals.
- CSV update: update or overwrite the row for todayβs date; otherwise append.
- Badges: generate SVG badges for totals and daily increments.
API example (PowerShell):
$uri = "https://api.github.com/repos/nntin/d-flows/actions/workflows/$($workflow.FileName)/runs?event=workflow_call&per_page=1"
Historical data retrieval (text parsed as CSV):
git fetch origin output:output
git show output:workflow-usage.csv | ConvertFrom-Csv
How gen_badges.ps1 contributes
Although gen_badges.ps1 primarily generates commit-based badges for repos in repos.json, it provides the shared badge infrastructure via common.psm1:
- Virtual environment setup:
Initialize-VirtualEnvironmentcreates a platform-specific venv and installs dependencies. - Badge templating:
New-Badgeleverages the Cookiecutter templatecookiecutter/cookiecutter-badges(custom left/right text, colors, filenames). - Output management: badges are staged in a temp dir and moved to
output/badges/with consistent naming.
The usage script calls New-Badge four times per tracked workflow: total and daily badges for both step-summary and discord-notify.
Complete flow
This creates a dynamic counter system where:
- The CSV file maintains historical usage data.
- Badges provide visual representations of current usage.
- Daily increments show adoption trends.
- All data is version-controlled on the
outputbranch.
The system runs periodically via a scheduled GitHub Actions workflow to keep statistics up to date for all repositories consuming d-flows.