-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
111 lines (93 loc) · 3.79 KB
/
action.yml
File metadata and controls
111 lines (93 loc) · 3.79 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
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@v3
with:
persist-credentials: true
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.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}"
echo "docs-dir: $DOCS_DIR"
echo "index-file: $INDEX_FILE"
echo "Action path: $ACTION_REPO_DIR"
echo "Copying from: $DEFAULT_INDEX"
echo "Target file: $TARGET_FILE"
if [ ! -f "$TARGET_FILE" ]; then
echo "No index file found in user repo. Copying default_index.html..."
mkdir -p "$(dirname "$TARGET_FILE")"
cp "$DEFAULT_INDEX" "$TARGET_FILE"
# Also copy enhanced visualization files if they exist in the action repo
ENHANCED_INDEX="$ACTION_REPO_DIR/docs/enhanced_index.html"
ENHANCED_JS="$ACTION_REPO_DIR/docs/enhanced_visualizer.js"
if [ -f "$ENHANCED_INDEX" ]; then
echo "Copying enhanced visualization files..."
cp "$ENHANCED_INDEX" "${DOCS_DIR}/enhanced_index.html"
cp "$ENHANCED_JS" "${DOCS_DIR}/enhanced_visualizer.js"
echo "Enhanced visualization available at: ${DOCS_DIR}/enhanced_index.html"
fi
else
echo "Index file already exists. Not overwriting."
# Still copy enhanced visualization if it doesn't exist
if [ ! -f "${DOCS_DIR}/enhanced_index.html" ]; then
ENHANCED_INDEX="$ACTION_REPO_DIR/docs/enhanced_index.html"
ENHANCED_JS="$ACTION_REPO_DIR/docs/enhanced_visualizer.js"
if [ -f "$ENHANCED_INDEX" ]; then
echo "Copying enhanced visualization files..."
cp "$ENHANCED_INDEX" "${DOCS_DIR}/enhanced_index.html"
cp "$ENHANCED_JS" "${DOCS_DIR}/enhanced_visualizer.js"
echo "Enhanced visualization available at: ${DOCS_DIR}/enhanced_index.html"
fi
fi
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 push
fi
shell: bash