Skip to content

just test

just test #189

name: Format *.cs files
on:
pull_request:
branches:
- 'main'
- 'preview/**'
- 'release/**'
- 'support/**'
paths:
- '**.cs'
permissions:
actions: read
contents: write
concurrency:
group: format-${{ github.head_ref || github.ref }}
cancel-in-progress: false
env:
dotnet-sdk-version: '9.x'
jobs:
formatting:
name: Format whitespace, code style and file header
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.head_ref || github.ref }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-sdk-version }}
- name: Format with .NET CLI
run: |
git checkout ${{ github.head_ref || github.ref }}
git pull origin ${{ github.head_ref || github.ref }}
dotnet format whitespace
dotnet format style
dotnet format analyzers --diagnostics IDE0005 IDE0073
working-directory: ${{ github.workspace }}
- if: runner.os == 'Windows'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- if: runner.os != 'Windows'
run: |
git config --global core.autocrlf true
git config --global core.eol lf
- name: Validate with .NET ${{ vars.DOTNET_SDK_VERSION }}
id: validate
shell: bash
run: |
set +e
git add .
git diff --quiet --exit-code --cached
echo has-changes="$?" >> $GITHUB_OUTPUT
set -e
working-directory: ${{ github.workspace }}
- name: Push changes to ${{ github.head_ref || github.ref }}
if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }}
run: |
git config user.name "$(git log -n 1 --pretty=format:%an)"
git config user.email "$(git log -n 1 --pretty=format:%ae)"
git commit -m "applied file header rule"
git pull origin ${{ github.head_ref || github.ref }}
git push origin ${{ github.head_ref || github.ref }}
working-directory: ${{ github.workspace }}