Skip to content

Run Playwright Website Tests & Swap Slots if successful #257

Run Playwright Website Tests & Swap Slots if successful

Run Playwright Website Tests & Swap Slots if successful #257

name: Run Playwright Website Tests & Swap Slots if successful
on:
workflow_run:
workflows: ["Deploy Website"]
types: [completed]
workflow_dispatch:
env:
WORKING_DIRECTORY: tests/web/Jordnaer.E2E.Tests
AZURE_WEBAPP_NAME: Jordnaer
RESOURCE_GROUP: Jordnaer
jobs:
playwright:
# Only run this if the workflow that triggered it was successful
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright/dotnet:v1.45.1-jammy
options: --user 1001
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
- name: Test
run: >
dotnet test "${{ env.WORKING_DIRECTORY }}"
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
--filter Category!=SkipInCi
env:
ConnectionStrings__AppConfig: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
Playwright_BaseUrl: "https://jordnaer-staging.azurewebsites.net/"
Playwright_Username: ${{ secrets.Playwright_Username }}
Playwright_Password: ${{ secrets.Playwright_Password }}
- name: Upload Screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: "${{ env.WORKING_DIRECTORY }}/bin/Debug/screenshots"
swap-deployment:
needs: playwright
runs-on: ubuntu-latest
concurrency:
group: Jordnaer-swap
cancel-in-progress: false
steps:
- name: Login to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.MINIMOEDER_AZURE_CREDENTIALS }}
- name: Swap Slots
run: >
az webapp deployment slot swap --name ${{ env.AZURE_WEBAPP_NAME }} --resource-group ${{ env.RESOURCE_GROUP }} --slot staging --target-slot production