Skip to content

Commit 9e5b61b

Browse files
authored
Docs & Website: Fixed build automation in CI (Fixes #1004) (#1214)
* websites/apidocs/docs.ps1: Use Set-Location to ensure dotnet tool commands are run from the repo root in CI * websites/site/site.ps1: Use Set-Location to ensure dotnet tool commands are run in the repo root in CI * .github/workflows (Lucene-Net-Documentation.yml + Lucene.Net.Website.yml): Updated actions tasks to the latest version
1 parent 2991483 commit 9e5b61b

4 files changed

Lines changed: 63 additions & 32 deletions

File tree

.github/workflows/Lucene-Net-Documentation.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757

5858
# Checkout the main repo with all history so we get all tags
5959
- name: Checkout Lucene.Net source
60-
uses: actions/checkout@v3
60+
uses: actions/checkout@v5
6161
with:
6262
path: main-repo
6363
fetch-depth: 0
@@ -119,12 +119,12 @@ jobs:
119119
shell: powershell
120120

121121
- name: Setup .NET 6 SDK
122-
uses: actions/setup-dotnet@v3
122+
uses: actions/setup-dotnet@v5
123123
with:
124124
dotnet-version: '6.0.x'
125125

126126
- name: Setup .NET 8 SDK
127-
uses: actions/setup-dotnet@v3
127+
uses: actions/setup-dotnet@v5
128128
with:
129129
dotnet-version: '8.0.x'
130130

@@ -133,7 +133,7 @@ jobs:
133133
shell: powershell
134134

135135
- name: Checkout Lucene.Net website
136-
uses: actions/checkout@v3
136+
uses: actions/checkout@v5
137137
with:
138138
repository: ${{ env.SITE_REPO }}
139139
ref: asf-site

.github/workflows/Lucene-Net-Website.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
# Checkout the main repo with all history so we get all tags
5252
- name: Checkout Lucene.Net source
53-
uses: actions/checkout@v3
53+
uses: actions/checkout@v5
5454
with:
5555
path: main-repo
5656
fetch-depth: 0
@@ -106,14 +106,14 @@ jobs:
106106
shell: powershell
107107

108108
- name: Upload website as build artifact
109-
uses: actions/upload-artifact@v4
109+
uses: actions/upload-artifact@v5
110110
if: ${{always()}}
111111
with:
112112
name: 'website'
113113
path: '${{github.workspace}}/main-repo/websites/site/_site'
114114

115115
- name: Checkout Lucene.Net website
116-
uses: actions/checkout@v3
116+
uses: actions/checkout@v5
117117
with:
118118
repository: ${{ env.SITE_REPO }}
119119
ref: asf-site

websites/apidocs/docs.ps1

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ $BreadcrumbPath = Join-Path -Path $ApiDocsFolder -ChildPath "docfx.global.subsit
6666
Write-Host "Restoring docfx tool..."
6767
$PreviousLocation = Get-Location
6868
Set-Location $RepoRoot
69-
dotnet tool restore
70-
Set-Location $PreviousLocation
69+
try {
70+
dotnet tool restore
71+
} finally {
72+
Set-Location $PreviousLocation
73+
}
74+
7175

7276
# delete anything that already exists
7377
if ($Clean) {
@@ -155,7 +159,13 @@ if ($? -and $DisableMetaData -eq $false) {
155159

156160
# build the output
157161
Write-Host "Building api metadata for $projFile..."
158-
& dotnet tool run docfx metadata $projFile --log "$DocFxLog" --logLevel $LogLevel
162+
$PreviousLocation = Get-Location
163+
Set-Location $RepoRoot
164+
try {
165+
& dotnet tool run docfx metadata $projFile --log "$DocFxLog" --logLevel $LogLevel
166+
} finally {
167+
Set-Location $PreviousLocation
168+
}
159169
}
160170
}
161171

@@ -183,7 +193,13 @@ if ($? -and $DisableBuild -eq $false) {
183193

184194
# build the output
185195
Write-Host "Building site output for $projFile..."
186-
& dotnet tool run docfx build $projFile --log "$DocFxLog" --logLevel $LogLevel --debug --maxParallelism 1
196+
$PreviousLocation = Get-Location
197+
Set-Location $RepoRoot
198+
try {
199+
& dotnet tool run docfx build $projFile --log "$DocFxLog" --logLevel $LogLevel --debug --maxParallelism 1
200+
} finally {
201+
Set-Location $PreviousLocation
202+
}
187203

188204
# Add the baseUrl to the output xrefmap, see https://github.com/dotnet/docfx/issues/2346#issuecomment-356054027
189205
$projFileJson = Get-Content $projFile | ConvertFrom-Json
@@ -201,16 +217,22 @@ if ($? -and $DisableBuild -eq $false) {
201217
if ($?) {
202218
$DocFxLog = Join-Path -Path $ApiDocsFolder "obj\docfx.site.json.log"
203219

204-
if ($ServeDocs -eq $false) {
205-
206-
# build the output
207-
Write-Host "Building docs..."
208-
& dotnet tool run docfx $DocFxJsonSite --log "$DocFxLog" --logLevel $LogLevel --debug --maxParallelism 1
209-
}
210-
else {
211-
# build + serve (for testing)
212-
Write-Host "starting website..."
213-
& dotnet tool run docfx $DocFxJsonSite --log "$DocFxLog" --logLevel $LogLevel --serve --port $StagingPort --debug --maxParallelism 1
220+
$PreviousLocation = Get-Location
221+
Set-Location $RepoRoot
222+
try {
223+
if ($ServeDocs -eq $false) {
224+
225+
# build the output
226+
Write-Host "Building docs..."
227+
& dotnet tool run docfx $DocFxJsonSite --log "$DocFxLog" --logLevel $LogLevel --debug --maxParallelism 1
228+
}
229+
else {
230+
# build + serve (for testing)
231+
Write-Host "starting website..."
232+
& dotnet tool run docfx $DocFxJsonSite --log "$DocFxLog" --logLevel $LogLevel --serve --port $StagingPort --debug --maxParallelism 1
233+
}
234+
} finally {
235+
Set-Location $PreviousLocation
214236
}
215237
}
216238

websites/site/site.ps1

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ if ($Clean) {
4646
# install docfx tool
4747
$PreviousLocation = Get-Location
4848
Set-Location $RepoRoot
49-
dotnet tool restore
50-
Set-Location $PreviousLocation
49+
try {
50+
dotnet tool restore
51+
} finally {
52+
Set-Location $PreviousLocation
53+
}
5154

5255
# delete anything that already exists
5356
if ($Clean) {
@@ -62,14 +65,20 @@ $DocFxJson = Join-Path -Path $SiteFolder "docfx.json"
6265
$DocFxLog = Join-Path -Path $SiteFolder "obj\docfx.log"
6366

6467
if($?) {
65-
if ($ServeDocs -eq $false) {
66-
# build the output
67-
Write-Host "Building docs..."
68-
& dotnet tool run docfx build $DocFxJson -l "$DocFxLog" --logLevel $LogLevel
69-
}
70-
else {
71-
# build + serve (for testing)
72-
Write-Host "starting website..."
73-
& dotnet tool run docfx $DocFxJson --serve --port $StagingPort
68+
$PreviousLocation = Get-Location
69+
Set-Location $RepoRoot
70+
try {
71+
if ($ServeDocs -eq $false) {
72+
# build the output
73+
Write-Host "Building docs..."
74+
& dotnet tool run docfx build $DocFxJson -l "$DocFxLog" --logLevel $LogLevel
75+
}
76+
else {
77+
# build + serve (for testing)
78+
Write-Host "starting website..."
79+
& dotnet tool run docfx $DocFxJson --serve --port $StagingPort
80+
}
81+
} finally {
82+
Set-Location $PreviousLocation
7483
}
7584
}

0 commit comments

Comments
 (0)