-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
81 lines (69 loc) · 2.43 KB
/
action.yml
File metadata and controls
81 lines (69 loc) · 2.43 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
name: "C# Code Graph Generator"
description: "Generates a JSON code graph via Roslyn, ensures a D3 index page from the action repository, and can commit changes."
branding:
icon: "share-2"
color: "black"
inputs:
source-path:
description: "Directory with .cs files"
required: false
default: "./src"
docs-dir:
description: "Directory for docs (graph.json + index.html)"
required: false
default: "docs"
index-file:
description: "HTML file name. If missing, we'll copy default_index.html from the action."
required: false
default: "index.html"
commit-changes:
description: "Set to 'true' to commit changes back"
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: true
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Build Roslyn tool
run: dotnet build --configuration Release ./tools/CodeAnalysisTool/CodeAnalysisTool.csproj
shell: bash
- name: Run Roslyn tool
run: dotnet run --project ./tools/CodeAnalysisTool/CodeAnalysisTool.csproj -- ${{ inputs.source-path }} ${{ inputs.docs-dir }}
shell: bash
- name: Ensure index.html from action repo
id: ensure_index
run: |
DOCS_DIR="${{ inputs.docs-dir }}"
INDEX_FILE="${{ inputs.index-file }}"
ACTION_REPO_DIR="${{ github.action_path }}"
DEFAULT_INDEX="$ACTION_REPO_DIR/default_index.html"
TARGET_FILE="${DOCS_DIR}/${INDEX_FILE}"
if [ ! -f "$TARGET_FILE" ]; then
echo "No index file found. Copying default visualizer..."
mkdir -p "$(dirname "$TARGET_FILE")"
cp "$DEFAULT_INDEX" "$TARGET_FILE"
else
echo "Index file already exists. Not overwriting."
fi
shell: bash
- name: Commit changes
if: ${{ inputs.commit-changes == 'true' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add ${{ inputs.docs-dir }}/graph.json ${{ inputs.docs-dir }}/index.html
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "Update code graph JSON & index [skip ci]"
git pull --rebase origin "${GITHUB_REF#refs/heads/}"
git push
fi
shell: bash