Skip to content

BuildSamplesAndSnippets #4321

BuildSamplesAndSnippets

BuildSamplesAndSnippets #4321

name: BuildSamplesAndSnippets
on:
workflow_dispatch:
schedule:
- cron: '0 2/4 * * 1-5' # Every 4 hours, Monday-Friday
env:
DOTNET_NOLOGO: true
DOTNET_ROLL_FORWARD: Major
jobs:
build-samples-and-snippets:
name: Build samples and snippets
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/[email protected]
with:
dotnet-version: 8.0.x
- name: Install .NET Aspire workload # To be removed once the base GitHub image has the Aspire workload 8.2
run: |
echo "Updating advertising manifests"
dotnet workload update --advertising-manifests-only
echo "Installing the Aspire workload"
dotnet workload install aspire
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: NuGet Cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
save-always: true
- name: Build affected samples and snippets
run: pwsh.exe -NoLogo -NonInteractive -File .\tools\build-samples-and-snippets.ps1
- name: Notify Slack on failure
if: ${{ failure() }}
shell: pwsh
run: |
$headers = @{
'Authorization' = "Bearer ${{ secrets.SLACK_TOKEN }}"
}
$body = @{
channel = 'docs'
text = "Failed to build samples and snippets on master: https://github.com/Particular/docs.particular.net/actions/workflows/build-samples-and-snippets.yml?query=branch%3Amaster"
username = 'Build samples and snippets'
icon_emoji = 'github_actions'
unfurl_links = false
unfurl_media = false
} | ConvertTo-Json
$result = Invoke-RestMethod -Method POST -Uri https://slack.com/api/chat.postMessage -ContentType "application/json; charset=utf-8" -Headers $headers -Body $body
Write-Output $result
exit $(If ($result.ok) { 0 } Else { 1 })
- name: Output failed failed samples and snippets
if: ${{ failure() }}
run: cat .\failed-samples-and-snippets.log