Bump the azurefunction group with 3 updates #3458
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
# https://docs.github.com/en/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure/deploying-to-azure-static-web-app | |
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig | |
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
# https://learn.microsoft.com/en-us/dotnet/devops/dotnet-test-github-action | |
name: Kaylumah.nl CI/CD | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened, closed, ready_for_review, converted_to_draft] | |
branches: | |
- main | |
permissions: | |
issues: write | |
contents: read | |
pull-requests: write | |
env: | |
BuildConfiguration: Release | |
TargetFramework: net8.0 | |
jobs: | |
fail_if_pull_request_is_draft: | |
if: github.event.pull_request.draft == true && (github.event_name == 'pull_request' && github.event.action != 'closed') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass. | |
run: exit 1 | |
build_and_test: | |
if: github.event.pull_request.draft == false && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')) | |
name: Build and Test (for ${{matrix.os}}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest, windows-latest, macOS-latest ] | |
outputs: | |
deployUrl: ${{ steps.outputJobVariables.outputs.baseUrl }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set TimeZone | |
uses: hoang-rio/set-timezone@v1.4 | |
with: | |
timezoneLinux: "Europe/Amsterdam" | |
timezoneMacos: "Europe/Amsterdam" | |
timezoneWindows: "W. Europe Standard Time" | |
- name: Sets env vars for PR | |
if: github.event_name == 'pull_request' | |
shell: pwsh | |
run: | | |
"PR_BUILD_ID=${{ github.event.number }}" >> $env:GITHUB_ENV | |
- id: outputJobVariables | |
shell: pwsh | |
run: | | |
$BaseUrl = ./tools/Get-BaseUrl.ps1 | |
"BaseUrl=$BaseUrl" >> $env:GITHUB_OUTPUT | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
- name: Install dependencies | |
shell: pwsh | |
run: | | |
dotnet restore | |
- name: Install dependencies (tools) | |
shell: pwsh | |
run: | | |
dotnet tool restore | |
- name: Build | |
shell: pwsh | |
run: | | |
$BuildId = "$env:GITHUB_RUN_ID" | |
$BuildNumber = "$env:GITHUB_RUN_NUMBER" | |
$BuildConfiguration = "${{ env.BuildConfiguration }}" | |
dotnet build --no-restore --configuration $BuildConfiguration /p:BuildId=$BuildId /p:BuildNumber=$BuildNumber /p:Version=1.0.0.$BuildNumber | |
- name: Test | |
shell: pwsh | |
run: | | |
$BuildConfiguration = "${{ env.BuildConfiguration }}" | |
dotnet test --no-restore --no-build --configuration $BuildConfiguration --verbosity normal --logger trx test/Unit/Test.Unit.csproj | |
# Consider naming the log file | |
# --logger "trx;LogFileName=test-results.trx" | |
- name: Run SiteGenerator | |
shell: pwsh | |
run: | | |
$BaseUrl = "${{ steps.outputJobVariables.outputs.baseUrl }}" | |
$BuildConfiguration = "${{ env.BuildConfiguration }}" | |
$TargetFramework = "${{ env.TargetFramework }}" | |
dotnet src/Component/Client/SiteGenerator/bin/$BuildConfiguration/$TargetFramework/Kaylumah.Ssg.Client.SiteGenerator.dll Site:Url=$BaseUrl | |
- name: Upload generated website | |
uses: actions/upload-artifact@v4 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
name: ${{ format('site-{0}', matrix.os) }} | |
path: dist | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload tools | |
uses: actions/upload-artifact@v4 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
name: ${{ format('tools-{0}', matrix.os) }} | |
path: tools | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload API | |
uses: actions/upload-artifact@v4 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
name: ${{ format('api-{0}', matrix.os) }} | |
path: api | |
if-no-files-found: error | |
retention-days: 1 | |
# Enable the following to do something with snapshot result(s) | |
# - name: Check Verify Results | |
# if: always() | |
# run: | | |
# $Output = & ./tools/Check-Snapshots.ps1 | |
# # -TargetFolder Test/Unit | |
# $Output = $Output | % { "." +$_ } | |
# if ($Output.count -gt 0) { | |
# New-Item -ItemType Directory "snapshots" | |
# foreach ($File in $Output) { | |
# Copy-Item $File -Destination snapshots | |
# } | |
# } | |
# shell: pwsh | |
# - uses: actions/upload-artifact@v4 | |
# if: always() | |
# with: | |
# name: "snapshots-${{matrix.os}}" | |
# path: snapshots | |
# if-no-files-found: ignore | |
# retention-days: 1 | |
deploy: | |
name: Deploy (for ubuntu-latest) | |
runs-on: ubuntu-latest | |
needs: build_and_test | |
steps: | |
# Needed until dotnet is publsihed... | |
- uses: actions/checkout@v4 | |
- name: Download site artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ format('site-{0}', 'ubuntu-latest') }} | |
path: dist | |
- name: Download tools artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ format('tools-{0}', 'ubuntu-latest') }} | |
path: tools | |
- name: Download api artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ format('api-{0}', 'ubuntu-latest') }} | |
path: api | |
- name: Use Node.js v20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Run npm steps | |
shell: pwsh | |
run: | | |
npm i --prefix dist | |
npm run build:prod --prefix dist | |
- name: Cleanup | |
shell: pwsh | |
run: | | |
./tools/Clean-Dist.ps1 | |
- name: Print site | |
shell: pwsh | |
run: | | |
tree dist | |
# Deploy the app to Azure Static Web Apps using the artifacts built previously | |
- name: Build And Deploy | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GREEN_FIELD_0353FEE03 }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) | |
action: "upload" | |
app_location: "dist" | |
api_location: "api" | |
output_location: "" | |
skip_app_build: true | |
skip_api_build: false | |
# Dotnet build is needed so we can use the playwright install | |
- name: Run E2e | |
shell: pwsh | |
env: | |
PLAYWRIGHT_TEST_BASE_URL: ${{ needs.build_and_test.outputs.deployUrl }} | |
run: | | |
Write-Host "Will run E2e against $Env:PLAYWRIGHT_TEST_BASE_URL" | |
$BuildConfiguration = "${{ env.BuildConfiguration }}" | |
$TargetFramework = "${{ env.TargetFramework }}" | |
dotnet build test/E2e --configuration $BuildConfiguration | |
& ./test/E2e/bin/$BuildConfiguration/$TargetFramework/playwright.ps1 install chromium --with-deps | |
dotnet test --no-build --configuration $BuildConfiguration test/E2e | |
close_pull_request: | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
name: Close Pull Request | |
steps: | |
- name: Close Pull Request | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GREEN_FIELD_0353FEE03 }} | |
action: "close" |