Format Update #246
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
name: Format Update | |
on: | |
schedule: | |
- cron: '0 0 */1 * *' | |
workflow_dispatch: | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'aers' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore | |
run: dotnet restore | |
- name: Run Format | |
run: dotnet format | |
- name: Check for changes | |
id: git-check | |
run: | | |
echo "========== check paths of modified files ==========" | |
git diff --name-only -- *.cs > files.txt | |
echo "=============== list modified files ===============" | |
tail files.txt | |
while IFS= read -r file | |
do | |
echo $file | |
if [[ $file != *.cs ]]; then | |
echo "This modified file is not in a c# file." | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
break | |
else | |
echo "has_changes=true" >> $GITHUB_OUTPUT | |
fi | |
done < files.txt | |
rm files.txt | |
- name: Commit Format Structs | |
if: steps.git-check.outputs.has_changes == 'true' | |
run: | | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git add . | |
git commit -m "Update Format" | |
git push |