commit-format.yml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # This is a basic workflow to help you get started with Actions
  2. name: Commit Format and Import Sort
  3. # Controls when the action will run.
  4. on:
  5. # Triggers the workflow on push or pull request events but only for the master branch
  6. push:
  7. branches: [ master ]
  8. pull_request:
  9. branches: [ master ]
  10. # Allows you to run this workflow manually from the Actions tab
  11. workflow_dispatch:
  12. # A workflow run is made up of one or more jobs that can run sequentially or in parallel
  13. jobs:
  14. # This workflow contains a single job called "build"
  15. build:
  16. # The type of runner that the job will run on
  17. runs-on: ubuntu-latest
  18. # Steps represent a sequence of tasks that will be executed as part of the job
  19. steps:
  20. # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  21. - uses: actions/checkout@v2
  22. # with: # https://github.com/stefanzweifel/git-auto-commit-action#checkout-the-correct-branch
  23. # ref: ${{ github.head_ref }}
  24. - uses: actions/setup-python@v2
  25. with:
  26. python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
  27. architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
  28. - uses: Gr1N/setup-poetry@v4
  29. - run: poetry install
  30. # - run: poetry --version
  31. # - run: ls -la
  32. - run: poetry run black --check .
  33. - name: Format if check failed
  34. if: failure()
  35. run: |
  36. printenv | grep GITHUB
  37. git config --global user.name 'ndbeals'
  38. git config --global user.email 'ndbeals@users.noreply.github.com'
  39. git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
  40. git remote -v
  41. git branch
  42. git status
  43. poetry run black .
  44. git status
  45. echo ready to commit
  46. git add .
  47. git commit -m "Code reformatted with psf/black"
  48. echo ready to push
  49. git push
  50. # git push --force origin
  51. - name: Isort
  52. run: poetry run isort --check .
  53. - name: Isort if check failed
  54. if: failure()
  55. run: |
  56. printenv | grep GITHUB
  57. git config --global user.name 'ndbeals'
  58. git config --global user.email 'ndbeals@users.noreply.github.com'
  59. git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
  60. git remote -v
  61. git branch
  62. git status
  63. poetry run isort --check .
  64. git status
  65. echo ready to commit
  66. git add .
  67. git commit -m "Imports sorted with isort"
  68. echo ready to push
  69. git push
  70. # git push --force origin
  71. # # Runs a single command using the runners shell
  72. # - name: Run a one-line script
  73. # run: echo Hello, world!
  74. # # Runs a set of commands using the runners shell
  75. # - name: Run a multi-line script
  76. # run: |
  77. # echo Add other actions to build,
  78. # echo test, and deploy your project.