summaryrefslogtreecommitdiff
path: root/.github/workflows/format_and_lint.yml
blob: cc2b812eae95b9250b5f190699a7e72a5595328b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Format and Lint

on:
  push:
    branches:
      - main, develop
  pull_request:
    branches:
      - main, develop

jobs:

  format_and_lint:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout HEAD
        uses: actions/checkout@v3
        with:
          ref: ${{ github.head_ref }}

      - name: Run flake8
        uses: microsoft/[email protected]
        with:
          flake8: true
          fail_on_error: true

      - name: Run yapf
        uses: mritunjaysharma394/autoyapf@v2
        with:
          args: --in-place --recursive .

      - name: Check for Modified Files
        id: git-check
        run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)

      - name: Push Changes
        if: steps.git-check.outputs.modified == 'true'
        run: |
          git config --global user.name 'github-actions'
          git config --global user.email '[email protected]'
          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
          git commit -am "chore: format and lint"