-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (148 loc) · 5.58 KB
/
Copy pathtree-viz.yml
File metadata and controls
167 lines (148 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Template created by https://github.com/XAOSTECH/dev-control
# See templates folder documentation for details.
# ============================================================================
# Git Tree Visualisation Workflow Template (tree-viz.yml)
# ============================================================================
#
# ORIGIN: https://github.com/XAOSTECH/dev-control
# This workflow template is part of the dev-control toolkit.
# See: https://github.com/XAOSTECH/dev-control/blob/main/workflows-templates/
#
# ============================================================================
#
# Generates an interactive HTML visualisation of the repository's git tree.
# Produces a fractal-style tree with waving leaves, showing commits, branches,
# merges, and tags in an animated, scrollable canvas.
#
# TRIGGERS:
# - Manual dispatch (workflow_dispatch)
# - Called by other workflows (workflow_call) e.g. update.yml
#
# WHAT IT DOES:
# 1. Checks out the full git history
# 2. Extracts commit data, branch info, and tags into JSON
# 3. Calculates organic tree layout positions
# 4. Renders interactive HTML with Canvas animations
# 5. Optionally renders static SVG for README embedding
# 6. Commits generated artefacts to .github/tree-viz/
#
# CONFIGURATION:
# - max_commits: Maximum number of commits to visualise (default: 500)
# - generate_svg: Whether to also produce a static SVG (default: true)
# - embed_readme: Whether to auto-inject SVG into README.md (default: true)
#
# ============================================================================
name: Git Tree Visualisation
on:
workflow_dispatch:
inputs:
max_commits:
description: 'Maximum commits to include in visualisation'
required: false
type: number
default: 500
generate_svg:
description: 'Generate static SVG alongside HTML'
required: false
type: boolean
default: true
embed_readme:
description: 'Auto-embed SVG into README.md'
required: false
type: boolean
default: true
workflow_call:
inputs:
max_commits:
description: 'Maximum commits to include'
required: false
type: number
default: 500
generate_svg:
description: 'Generate static SVG'
required: false
type: boolean
default: true
embed_readme:
description: 'Auto-embed SVG into README'
required: false
type: boolean
default: true
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
generate-tree:
name: Generate Git Tree Visualisation
runs-on: ubuntu-latest
steps:
- name: Generate App Token
id: app_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets['XB_AI'] }}
private-key: ${{ secrets['XB_PK'] }}
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ steps.app_token.outputs.token }}
- name: Setup bot identity
uses: XAOSTECH/dev-control/.github/actions/identity@b067f72ca7f849b734a45634f23581a739d5146f # v2.0.0
with:
gpg-private-key: ${{ secrets['XB_GK'] }}
gpg-passphrase: ${{ secrets['XB_GP'] }}
user-token: ${{ secrets['XB_UT'] }}
bot-name: ${{ vars.BOT_NAME || 'xaos-bot' }}
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yqq jq
- name: Checkout dev-control
uses: actions/checkout@v6
with:
repository: XAOSTECH/dev-control
path: .dev-control
sparse-checkout: |
scripts/lib/git/tree-viz.sh
scripts/lib/git/tree-layout.sh
scripts/lib/git/tree-render-html.sh
scripts/lib/git/tree-render-svg.sh
scripts/lib/colours.sh
scripts/lib/print.sh
scripts/create-tree.sh
- name: Generate tree visualisation
env:
MAX_COMMITS: ${{ inputs.max_commits || 500 }}
GENERATE_SVG: ${{ inputs.generate_svg && '--svg-only' || '' }}
EMBED_README: ${{ inputs.embed_readme }}
run: |
cd "$GITHUB_WORKSPACE"
# Build args
ARGS=("--max-commits" "$MAX_COMMITS" "--output-dir" ".github/tree-viz")
[[ "$EMBED_README" != "true" ]] && ARGS+=("--no-embed")
bash .dev-control/scripts/create-tree.sh "${ARGS[@]}"
- name: Commit and push
run: |
cd "$GITHUB_WORKSPACE"
if git diff --quiet && git diff --cached --quiet; then
echo "ℹ️ No changes to commit"
exit 0
fi
git add .github/tree-viz/
[[ -f README.md ]] && git add README.md
[[ -f docs/README.md ]] && git add docs/README.md
git commit -m "chore: update git tree visualisation" \
-m "Auto-generated by tree-viz workflow" \
-m "See: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
git push
echo "## 🌳 Tree Visualization Updated" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Generated files:" >> $GITHUB_STEP_SUMMARY
echo "- \`.github/tree-viz/git-tree.html\` (interactive)" >> $GITHUB_STEP_SUMMARY
echo "- \`.github/tree-viz/git-tree-data.json\` (data)" >> $GITHUB_STEP_SUMMARY
echo "- \`.github/tree-viz/git-tree.svg\` (static)" >> $GITHUB_STEP_SUMMARY
- name: Cleanup dev-control checkout
if: always()
run: rm -rf .dev-control