name: Lint

on: pull_request

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Lint
        uses: golangci/golangci-lint-action@v2
        with:
          version: latest
      - name: Format code
        run: |
          if [ $(find . ! -path "./vendor/*" -name "*.go" -exec gofmt -s -d {} \;|wc -l) -gt 0 ]; then
           find . ! -path "./vendor/*" -name "*.go" -exec gofmt -s -d {} \;
           exit 1
          fi
