-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (109 loc) · 4.27 KB
/
Copy pathdeploy.yml
File metadata and controls
126 lines (109 loc) · 4.27 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
name: Deploy Documentation
# Builds the C# API reference (DocFX → Markdown) and the Docusaurus site,
# then publishes to GitHub Pages.
#
# Pipeline:
# 1. dotnet build — compile the SDK libraries (produces the DLLs + XML docs).
# 2. docfx metadata — extract API YAML, then dfmg (DocFxMarkdownGen) → docs/api Markdown.
# 3. npm build — Docusaurus builds the static site (consuming docs/api).
# 4. deploy — upload the artifact and publish to GitHub Pages.
#
# The build job runs on Windows because one library targets .NET Framework 4.8 +
# WPF (CodeFactory.WinVs.Wpf), which cannot be built on Linux, and DocFX reads
# the compiled assemblies.
on:
push:
branches: [main]
paths:
- 'src/**'
- 'website/**'
- 'docfx/**'
- '.github/workflows/deploy.yml'
workflow_dispatch:
# Allow the GITHUB_TOKEN to deploy to Pages and verify the deployment origin.
permissions:
contents: read
pages: write
id-token: write
# Only one concurrent deployment; let an in-progress run finish.
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
name: Build site
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
# --- Toolchains -------------------------------------------------------
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
cache-dependency-path: website/package-lock.json
# --- Step 1: dotnet build --------------------------------------------
# Build the three library projects. DocFX reads the resulting DLLs (and
# their XML doc files) directly, which avoids invoking MSBuild from inside
# DocFX (fragile against preview VS toolchains).
- name: Build SDK libraries
run: |
dotnet build src/CodeFactoryForWindows/CodeFactory/CodeFactory.csproj -c Release
dotnet build src/CodeFactoryForWindows/CodeFactory.WinVs/CodeFactory.WinVs.csproj -c Release
dotnet build src/CodeFactoryForWindows/CodeFactory.WinVs.Wpf/CodeFactory.WinVs.Wpf.csproj -c Release
# --- Step 2: docfx metadata + Markdown bridge ------------------------
# docfx is the metadata extractor; docfxmarkdowngen installs the `dfmg`
# command that converts the YAML to Markdown using docfx/config.yaml.
- name: Install DocFX and Markdown generator
run: |
dotnet tool install -g docfx
dotnet tool install -g docfxmarkdowngen
echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
- name: Generate API metadata (YAML)
working-directory: docfx
run: docfx metadata docfx.json --logLevel Warning
- name: Convert API metadata to Markdown
working-directory: docfx
# `dfmg` loads ./config.yaml from the working directory.
run: dfmg
- name: Normalize generated API links
# Appends .md to relative cross-reference links (so Docusaurus resolves
# them via the doc graph), links BCL (System.*/Microsoft.*) types to
# Microsoft Learn, and drops empty namespace index entries.
run: node docfx/postprocess-api.mjs
- name: Polish generated API index title
working-directory: website/docs/api
run: |
sed -i 's/^title: Index$/title: API Reference/' index.md
sed -i 's/^sidebar_label: Index$/sidebar_label: Overview/' index.md
# --- Step 3: npm build -----------------------------------------------
- name: Install site dependencies
working-directory: website
run: npm ci
- name: Build Docusaurus site
working-directory: website
run: npm run build
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: website/build
# --- Step 4: deploy -----------------------------------------------------
deploy:
name: Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4