Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
120 lines (114 loc) · 5 KB
/
Copy pathaction.yml
File metadata and controls
120 lines (114 loc) · 5 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
name: Build DocFX OCI Artifact from Codebelt
description: An opinionated action that generates DocFX metadata and exports a verified multi-platform OCI archive from the checked out revision.
inputs:
version:
description: Human-selected SemVer release version without the v prefix.
required: true
revision:
description: Full 40-character commit SHA being released.
required: true
output-path:
description: Absolute path for the OCI archive; a .sha256 file is created alongside it.
required: true
docfx-config:
description: DocFX configuration path relative to the workspace.
required: false
default: .docfx/docfx.json
dockerfile:
description: Workspace-relative Dockerfile. Defaults to the bundled framework-view Dockerfile when enabled and .docfx/Dockerfile.docfx otherwise.
required: false
docfx-version:
description: DocFX CLI version for legacy metadata. Framework-view builds use the CLI in the builder image.
required: false
default: 2.81.0
framework-views:
description: Set to true to build native documentation views for the evaluated project frameworks.
required: false
default: 'false'
platforms:
description: Comma-separated target platform list for the OCI image.
required: false
default: linux/amd64,linux/arm64
outputs:
archive-path:
description: Absolute path to the verified OCI archive.
value: ${{ steps.verify.outcome == 'success' && steps.verify.outputs.digest && steps.build.outputs.archive-path || '' }}
checksum-path:
description: Absolute path to the archive SHA-256 file.
value: ${{ steps.verify.outcome == 'success' && steps.verify.outputs.digest && steps.build.outputs.checksum-path || '' }}
digest:
description: SHA-256 digest of the embedded OCI image index.
value: ${{ steps.verify.outcome == 'success' && steps.verify.outputs.digest || '' }}
runs:
using: composite
steps:
- name: Require .NET 10 SDK
shell: pwsh
run: |
$dotnet = Get-Command dotnet -ErrorAction SilentlyContinue
if ($null -eq $dotnet) {
throw "This action requires the .NET 10 SDK. Install .NET 10 before invoking codebeltnet/docfx-oci-build."
}
$installedSdkLines = @(& dotnet --list-sdks 2>&1)
if ($LASTEXITCODE -ne 0) {
throw "Failed to enumerate installed .NET SDKs with 'dotnet --list-sdks'."
}
$installedSdkVersions = @(
foreach ($line in $installedSdkLines) {
$version = ($line -split '\s+', 2)[0]
if ($version) {
$version
}
}
)
$compatibleSdkVersions = @(
foreach ($version in $installedSdkVersions) {
if ($version -match '^(?<major>\d+)\.' -and [int]$Matches.major -ge 10) {
$version
}
}
)
if ($compatibleSdkVersions.Count -eq 0) {
$installedSdkDisplay = if ($installedSdkVersions.Count -gt 0) {
$installedSdkVersions -join ', '
} else {
'none'
}
throw "This action requires the .NET 10 SDK or newer. Install .NET 10 or newer before invoking codebeltnet/docfx-oci-build. Installed SDKs: $installedSdkDisplay"
}
- id: build
name: Build documentation and export the OCI image archive
shell: pwsh
env:
ACTION_PATH: ${{ github.action_path }}
WORKSPACE_ROOT: ${{ github.workspace }}
RELEASE_VERSION: ${{ inputs.version }}
RELEASE_REVISION: ${{ inputs.revision }}
OUTPUT_PATH: ${{ inputs.output-path }}
DOCFX_CONFIG: ${{ inputs.docfx-config }}
DOCKERFILE: ${{ inputs.dockerfile }}
DOCFX_VERSION: ${{ inputs.docfx-version }}
FRAMEWORK_VIEWS: ${{ inputs.framework-views }}
PLATFORMS: ${{ inputs.platforms }}
run: |
& "$env:ACTION_PATH/scripts/build-docfx-oci.ps1" -Version $env:RELEASE_VERSION -Revision $env:RELEASE_REVISION -OutputPath $env:OUTPUT_PATH -WorkspaceRoot $env:WORKSPACE_ROOT -DocfxConfig $env:DOCFX_CONFIG -Dockerfile $env:DOCKERFILE -DocfxVersion $env:DOCFX_VERSION -Platforms $env:PLATFORMS -FrameworkViews $env:FRAMEWORK_VIEWS
- id: verify
name: Verify the newly built OCI artifact
uses: codebeltnet/oci-artifact-verify@v1
with:
archive-path: ${{ steps.build.outputs.archive-path }}
checksum-path: ${{ steps.build.outputs.checksum-path }}
version: ${{ inputs.version }}
revision: ${{ inputs.revision }}
- name: Remove unverified artifacts on verification failure
if: ${{ always() && steps.build.outcome == 'success' && (steps.verify.outcome != 'success' || !steps.verify.outputs.digest) }}
shell: pwsh
env:
ARCHIVE_PATH: ${{ steps.build.outputs.archive-path }}
CHECKSUM_PATH: ${{ steps.build.outputs.checksum-path }}
run: |
Remove-Item -LiteralPath $env:ARCHIVE_PATH, $env:CHECKSUM_PATH -ErrorAction Stop
throw 'OCI verification did not complete with a verified digest.'
branding:
icon: 'umbrella'
color: 'blue'