Adds automatic (based on CSS prefers-color-scheme) light/dark mode. #372
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: Build and Test .NET projects | |
on: | |
push: | |
branches: [ "main" ] | |
paths: [ "src/**" ] | |
pull_request: | |
branches: [ "main" ] | |
types: [opened, synchronize, reopened, closed] | |
paths: [ "src/**" ] | |
workflow_dispatch: | |
branches: [ "main" ] | |
jobs: | |
build: | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | |
# needs: [code-formatting] | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./src | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Unit Test | |
run: dotnet test --no-build --verbosity normal | |
working-directory: ./src/TagzApp.UnitTest | |
playwright: | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | |
# needs: [code-formatting] | |
name: 'Playwright Tests' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./src/TagzApp.WebTest | |
timeout-minutes: 10 | |
container: | |
image: mcr.microsoft.com/playwright/dotnet:v1.37.1-jammy | |
options: --ipc=host | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- run: dotnet build | |
- name: Execute Playwright tests | |
env: | |
TestHostStartDelay: 1000 | |
run: dotnet test --no-build | |
image: | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'FritzAndFriends') | |
name: 'Create docker image for Web' | |
runs-on: ubuntu-latest | |
needs: [playwright] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y%m%d')" | |
- name: Docker Login | |
uses: docker/login-action@v2.2.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker Metadata action | |
id: meta | |
uses: docker/metadata-action@v4.6.0 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
latest | |
${{ steps.date.outputs.date }}.${{ github.run_attempt }} | |
- uses: docker/build-push-action@v4.1.1 | |
with: | |
context: . | |
file: ./src/TagzApp.Web/dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
Build_Version: ${{ steps.date.outputs.date }}.${{ github.run_attempt }} | |
# code-formatting: | |
# if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# with: | |
# fetch-depth: 0 | |
# - name: Get git diff | |
# id: diff | |
# run: | | |
# git fetch origin main | |
# { | |
# echo 'files<<EOF' | |
# git diff origin/main --name-only --diff-filter=d -- "*.css" "*.js" "*.cs" | |
# echo EOF | |
# } >> "$GITHUB_OUTPUT" | |
# - name: Get changed C# files | |
# id: changed_cs | |
# run: | | |
# { | |
# echo 'files<<EOF' | |
# echo "${{ steps.diff.outputs.files }}" | grep -E "\.cs$" | paste -sd " " | |
# echo EOF | |
# } >> "$GITHUB_OUTPUT" | |
# - name: Add formatting rules to .editorconfig | |
# if: steps.changed_cs.outputs.files != '' | |
# run: | | |
# echo "" >> src/.editorconfig | |
# echo "[*.cs]" >> src/.editorconfig | |
# echo "dotnet_diagnostic.IDE0005.severity = error" >> src/.editorconfig # Remove unnecessary using directives | |
# echo "dotnet_diagnostic.IDE0090.severity = error" >> src/.editorconfig # Simplify new expression | |
# echo "dotnet_diagnostic.IDE0003.severity = error" >> src/.editorconfig # this and Me preferences | |
# echo "dotnet_diagnostic.IDE0009.severity = error" >> src/.editorconfig # this and Me preferences | |
# - name: Setup .NET | |
# if: steps.changed_cs.outputs.files != '' | |
# uses: actions/setup-dotnet@v3 | |
# with: | |
# dotnet-version: 7.0.x | |
# - name: Run dotnet format | |
# if: steps.changed_cs.outputs.files != '' | |
# id: dotnet-format | |
# run: | | |
# echo "Running dotnet format on: ${{ steps.changed_cs.outputs.files }}" | |
# result=$(dotnet format src/TagzApp.sln --verbosity normal --exclude src/TagzApp.Web/Migrations --include ${{ steps.changed_cs.outputs.files }}) | |
# echo "Format result:" | |
# echo "$result" | |
# count=$(echo "$result" | grep -c "Formatted code file" || true) | |
# echo "Number of files Format formatted: $count" | |
# echo "count=$count" >> "$GITHUB_OUTPUT" | |
# - name: Get changed JS/CSS files | |
# id: changed_js_css | |
# run: | | |
# { | |
# echo 'files<<EOF' | |
# echo "${{ steps.diff.outputs.files }}" | grep -E "\.(js|css)$" | paste -sd " " | |
# echo EOF | |
# } >> "$GITHUB_OUTPUT" | |
# - name: Setup Node | |
# if: steps.changed_js_css.outputs.files != '' | |
# uses: actions/setup-node@v3 | |
# with: | |
# node-version: lts/* | |
# - name: Run prettier | |
# if: steps.changed_js_css.outputs.files != '' | |
# id: prettier | |
# run: | | |
# echo "Running prettier on: ${{ steps.changed_js_css.outputs.files }}" | |
# npm install prettier | |
# result=$(npx prettier --write --list-different ${{ steps.changed_js_css.outputs.files }}) | |
# echo "Prettier result:" | |
# echo "$result" | |
# count=$(echo "$result" | grep -cE "\.(js|css)$" || true) | |
# echo "Number of files Prettier formatted: $count" | |
# echo "count=$count" >> "$GITHUB_OUTPUT" | |
# - name: Commit if changes | |
# if: steps.prettier.outputs.count > 0 || steps.dotnet-format.outputs.count > 0 | |
# run: | | |
# git config user.name "github-actions" | |
# git config user.email "github-actions@github.com" | |
# git add *.cs *.js *.css | |
# echo "$(git status)" | |
# git commit -m "Applying formatting changes through GitHub Actions" | |
# git push origin HEAD:${{ github.head_ref }} |