style.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (c) 2008-2022 the Urho3D project
  2. # License: MIT
  3. ---
  4. name: Style
  5. on:
  6. workflow_dispatch:
  7. schedule: [ cron: '0 0 * * *' ]
  8. jobs:
  9. Style:
  10. name: Style
  11. runs-on: ubuntu-latest
  12. if: github.repository == 'urho3d/Urho3D'
  13. steps:
  14. - name: Remove end-line spaces
  15. shell: bash {0} # Allow catching errors
  16. run: |
  17. #set -x # Echo commands
  18. git config --global user.email "urho3d[bot]@users.noreply.github.com"
  19. git config --global user.name "Urho3D[bot]"
  20. # Someone can push to the repo at the same time, so try several times
  21. for (( i = 0; i < 4; ++i ))
  22. do
  23. git clone https://github.com/${{ github.repository }} engine_repo
  24. cd engine_repo
  25. find ./bin -type f \( -name '*.glsl' -or -name '*.hlsl' -or -name '*.xml' \) -exec perl -i -pe 's/[ \t]+(\r?\n)/$1/g' {} +
  26. find ./cmake -type f -exec perl -i -pe 's/[ \t]+(\r?\n)/$1/g' {} +
  27. find ./Source/Urho3D -type f -exec perl -i -pe 's/[ \t]+(\r?\n)/$1/g' {} +
  28. git add -A
  29. git diff-index --quiet HEAD || git commit -m "Remove end-line spaces" # Create the commit if there are changes
  30. git push https://oauth2:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
  31. EXIT_CODE=$? # Save exit code of the previous command
  32. cd ..
  33. if (( $EXIT_CODE == 0 ))
  34. then
  35. break
  36. else
  37. echo "========== One more try =========="
  38. rm -rf engine_repo
  39. sleep 20
  40. fi
  41. done
  42. ...
  43. # vi: set ts=2 sw=2 expandtab: