Bump actions/setup-node from 4.0.3 to 4.0.4 #4161
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- '**/*.gitattributes' | |
- '**/*.gitignore' | |
- '**/*.md' | |
pull_request: | |
branches: | |
- main | |
- dotnet-vnext | |
- dotnet-nightly | |
workflow_dispatch: | |
env: | |
APPLICATION_URL_PROD: https://costellobot.martincostello.com | |
AZURE_WEBAPP_NAME: costellobot-martincostello | |
CONTAINER_REGISTRY: '${{ github.repository_owner }}.azurecr.io' | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_GENERATE_ASPNET_CERTIFICATE: false | |
DOTNET_NOLOGO: true | |
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 | |
FORCE_COLOR: 1 | |
NUGET_XMLDOC_MODE: skip | |
TERM: xterm | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
env: | |
PUBLISH_CONTAINER: ${{ github.event.repository.fork == false && github.ref_name == github.event.repository.default_branch && matrix.os == 'ubuntu-latest' }} | |
outputs: | |
container-tag: ${{ steps.publish-container.outputs.container-tag }} | |
permissions: | |
attestations: write | |
contents: read | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: macos-latest | |
os-name: macos | |
- os: ubuntu-latest | |
os-name: linux | |
- os: windows-latest | |
os-name: windows | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1 | |
- name: Setup Node | |
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 | |
with: | |
node-version: '20' | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: pwsh | |
run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT} | |
- name: Setup npm cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
id: npm-cache | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node- | |
- name: Setup NuGet cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }} | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Setup Playwright cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
key: ${{ runner.os }}-playwright-${{ hashFiles('Directory.Packages.props') }} | |
path: | | |
~/AppData/Local/ms-playwright | |
~/.cache/ms-playwright | |
~/Library/Caches/ms-playwright | |
- name: Install .NET Workloads | |
shell: pwsh | |
run: dotnet workload restore --skip-manifest-update | |
- name: Build, Test and Publish | |
id: build | |
shell: pwsh | |
run: ./build.ps1 | |
- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 | |
name: Upload coverage to Codecov | |
with: | |
files: ./artifacts/coverage/coverage.cobertura.xml,./src/Costellobot/coverage/lcov.info | |
flags: ${{ matrix.os-name }} | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Docker log in | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
if: env.PUBLISH_CONTAINER == 'true' | |
with: | |
registry: ${{ env.CONTAINER_REGISTRY }} | |
username: ${{ secrets.ACR_REGISTRY_USERNAME }} | |
password: ${{ secrets.ACR_REGISTRY_PASSWORD }} | |
- name: Publish container | |
id: publish-container | |
if: runner.os == 'Linux' | |
shell: pwsh | |
env: | |
ContainerRegistry: ${{ env.PUBLISH_CONTAINER == 'true' && env.CONTAINER_REGISTRY || '' }} | |
run: | | |
dotnet publish ./src/Costellobot --arch x64 --os linux -p:PublishProfile=DefaultContainer | |
- name: Attest container image | |
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3 | |
if: steps.publish-container.outputs.container-digest != '' | |
with: | |
push-to-registry: true | |
subject-digest: ${{ steps.publish-container.outputs.container-digest }} | |
subject-name: ${{ steps.publish-container.outputs.container-image }} | |
- name: Publish screenshots | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
if: ${{ !cancelled() }} | |
with: | |
name: screenshots-${{ matrix.os-name }} | |
path: ./artifacts/screenshots/* | |
if-no-files-found: ignore | |
- name: Publish traces | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
if: ${{ !cancelled() }} | |
with: | |
name: traces-${{ matrix.os-name }} | |
path: ./artifacts/traces/* | |
if-no-files-found: ignore | |
- name: Publish videos | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
if: ${{ !cancelled() }} | |
with: | |
name: videos-${{ matrix.os-name }} | |
path: ./artifacts/videos/* | |
if-no-files-found: ignore | |
- name: Upload any crash dumps | |
shell: pwsh | |
if: | | |
!cancelled() && | |
steps.build.outcome == 'failure' && | |
github.event.repository.fork == false && | |
github.event.sender.login != 'dependabot[bot]' | |
env: | |
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.CRASH_DUMPS_STORAGE_CONNECTION_STRING }} | |
PSCOMPRESSION_VERSION: '2.0.6' | |
run: | | |
$dumps = Get-ChildItem -Path ${env:GITHUB_WORKSPACE} -Filter "*.dmp" -Recurse | |
if ($null -ne $dumps) { | |
$container = ${env:GITHUB_REPOSITORY}.Replace("/", "-") | |
az storage container create --name $container --public-access off | Out-Null | |
Install-Module PSCompression -RequiredVersion ${env:PSCOMPRESSION_VERSION} -AcceptLicense -Force -Scope CurrentUser | |
$dumps | ForEach-Object { | |
$zipPath = $_.FullName + ".zip" | |
$zipName = $_.Name + ".zip" | |
Write-Output "Compressing crash dump $($_.Name)..." | |
Compress-ZipArchive -Path $_.FullName -Destination $zipPath | |
az storage blob upload ` | |
--container-name $container ` | |
--file $zipPath ` | |
--name $zipName ` | |
--metadata "GITHUB_RUN_ATTEMPT=${env:GITHUB_RUN_ATTEMPT}" "GITHUB_WORKFLOW=${env:GITHUB_SERVER_URL}/${env:GITHUB_REPOSITORY}/actions/runs/${env:GITHUB_RUN_ID}" "RUNNER_OS=${env:RUNNER_OS}" ` | |
--overwrite true | |
if ($LASTEXITCODE -eq 0) { | |
Write-Output "::notice::Uploaded crash dump $($_.Name) to Azure Storage." | |
} | |
} | |
} | |
deploy: | |
if: github.event.repository.fork == false && github.ref_name == github.event.repository.default_branch | |
name: deploy-production | |
needs: build | |
runs-on: ubuntu-latest | |
concurrency: production_environment | |
environment: | |
name: production | |
url: ${{ env.APPLICATION_URL_PROD }} | |
permissions: | |
id-token: write | |
steps: | |
- name: Azure log in | |
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Deploy container to Azure App Service | |
uses: azure/webapps-deploy@2fdd5c3ebb4e540834e86ecc1f6fdcd5539023ee # v3.0.2 | |
with: | |
app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
images: ${{ needs.build.outputs.container-tag }} | |
- name: Check application health | |
shell: pwsh | |
env: | |
APPLICATION_URL: ${{ env.APPLICATION_URL_PROD }} | |
run: | | |
$delay = 10 | |
$limit = 15 | |
$success = $false | |
for ($i = 0; $i -lt $limit; $i++) { | |
$response = $null | |
try { | |
$response = Invoke-WebRequest -Uri "${env:APPLICATION_URL}/version" -Method Get -UseBasicParsing | |
} catch { | |
$response = $_.Exception.Response | |
} | |
if (($null -ne $response) -And ($response.StatusCode -eq 200)) { | |
$json = $response.Content | ConvertFrom-Json | |
$app = $json.application | |
$version = $app -eq $null ? "" : $app.version | |
if ((-Not [string]::IsNullOrWhiteSpace($version)) -And $version.Contains(${env:GITHUB_SHA})) { | |
$success = $true | |
break | |
} | |
} | |
Start-Sleep -Seconds $delay | |
} | |
if (-Not $success) { | |
throw "${env:APPLICATION_URL} did not return a successful status code and the expected version within the time limit after $limit attempts." | |
} | |
test: | |
name: test-production | |
needs: deploy | |
runs-on: ubuntu-latest | |
concurrency: production_environment | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1 | |
- name: Setup NuGet cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }} | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Setup Playwright cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
key: ${{ runner.os }}-playwright-${{ hashFiles('Directory.Packages.props') }} | |
path: | | |
~/AppData/Local/ms-playwright | |
~/.cache/ms-playwright | |
~/Library/Caches/ms-playwright | |
- name: Run end-to-end tests | |
shell: pwsh | |
run: dotnet test ./tests/Costellobot.EndToEndTests --configuration Release --logger "GitHubActions;report-warnings=false" | |
env: | |
APPLICATION_URL: ${{ env.APPLICATION_URL_PROD }} | |
- name: Publish screenshots | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
if: ${{ !cancelled() }} | |
with: | |
name: screenshots-e2e | |
path: ./artifacts/screenshots/* | |
if-no-files-found: ignore | |
- name: Publish traces | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
if: ${{ !cancelled() }} | |
with: | |
name: traces-e2e | |
path: ./artifacts/traces/* | |
if-no-files-found: ignore | |
- name: Publish videos | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
if: ${{ !cancelled() }} | |
with: | |
name: videos-e2e | |
path: ./artifacts/videos/* | |
if-no-files-found: ignore |