Update starters for v1.0.0 RC1 #124
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 runs the dotnet formatter on all c-sharp code. | |
# | |
name: dotnet-format | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ "main", "feature*" ] | |
jobs: | |
check-format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: changed-files | |
uses: jitterbit/get-changed-files@v1 | |
- name: No C# files changed | |
id: no-csharp | |
if: steps.changed-files.outputs.added_modified == '' | |
run: echo "No C# files changed" | |
# This step will loop over the changed files and find the nearest .csproj file for each one, then store the unique csproj files in a variable | |
- name: Find csproj files | |
id: find-csproj | |
if: steps.changed-files.outputs.added_modified != '' | |
run: | | |
csproj_files=() | |
for file in ${{ steps.changed-files.outputs.added_modified }}; do | |
echo "$file was changed" | |
dir="$GITHUB_WORKSPACE/$file" | |
while [[ $dir != "." && $dir != "/" && $dir != $GITHUB_WORKSPACE ]]; do | |
if find "$dir" -maxdepth 1 -name "*.csproj" -print -quit | grep -q .; then | |
csproj_files+=("$(find "$dir" -maxdepth 1 -name "*.csproj" -print -quit)") | |
break | |
fi | |
dir=$(dirname $dir) | |
done | |
done | |
csproj_files=($(printf "%s\n" "${csproj_files[@]}" | sort -u)) | |
echo "Found ${#csproj_files[@]} unique csproj files: ${csproj_files[*]}" | |
echo "::set-output name=csproj_files::${csproj_files[*]}" | |
- name: Install dotnet-format tool | |
if: steps.changed-files.outputs.added_modified != '' | |
run: dotnet tool install -g dotnet-format | |
# This step will run dotnet format on each of the unique csproj files and fail if any changes are made | |
- name: Run dotnet format | |
if: steps.changed-files.outputs.added_modified != '' | |
run: | | |
for csproj in ${{ steps.find-csproj.outputs.csproj_files }}; do | |
echo "Running dotnet format on $csproj" | |
dotnet format $csproj --verify-no-changes --verbosity detailed | |
done |