diff --git a/.github/workflows/pep8-push.yml b/.github/workflows/pep8-push.yml new file mode 100644 index 0000000..a5fe195 --- /dev/null +++ b/.github/workflows/pep8-push.yml @@ -0,0 +1,15 @@ +name: PEP8 check (push) + +on: [push] + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: 'Run PEP8' + uses: quentinguidee/pep8-action@v1 + id: run_pep8 + with: + arguments: '--max-line-length=79' + continue-on-error: false diff --git a/.github/workflows/pep8.yml b/.github/workflows/pep8.yml index 81acc69..b8b352e 100644 --- a/.github/workflows/pep8.yml +++ b/.github/workflows/pep8.yml @@ -1,5 +1,3 @@ -# By @quentinguidee, licenced under the MIT license. - name: PEP8 check on: [pull_request_target] @@ -9,46 +7,32 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Setup Python - uses: actions/setup-python@master with: - version: 3.8 - - name: Download pycodestyle - run: | - pip install pycodestyle - - name: Run pycodestyle - id: run_pycodestyle - run: | - echo "::set-output name=pycodestyle::$(pycodestyle .)" - pycodestyle . - continue-on-error: true - - if: steps.run_pycodestyle.outcome == 'failure' - name: Comment (failure) - uses: actions/github-script@v3 - env: - OUTPUT: ${{ steps.run_pycodestyle.outputs.pycodestyle }} + ref: ${{ github.event.pull_request.head.sha }} + - name: 'Run PEP8' + uses: quentinguidee/pep8-action@v1 + id: run_pep8 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const title = "Beep Beep! I found some formatting errors in this PR: \n" - - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: title + ' \n``` \n' + process.env.OUTPUT + ' \n```' - }) - - if: steps.run_pycodestyle.outcome == 'success' - name: Comment (success) + arguments: '--max-line-length=79' + continue-on-error: true + - name: 'Comment' uses: actions/github-script@v3 env: - OUTPUT: ${{ steps.run_pycodestyle.outputs.pycodestyle }} + EXIT_CODE: ${{ steps.run_pep8.outputs.exit-code }} + OUTPUT: ${{ steps.run_pep8.outputs.output }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + var message; + if (process.env.EXIT_CODE === '0') { + message = 'Beep Beep! No formatting errors detected! :partying_face:' + } else { + message = 'Beep Beep! I found some formatting errors in this PR: \n' + message += ' \n``` \n' + process.env.OUTPUT + ' \n```' + } github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: 'Beep Beep! No formatting errors detected! :partying_face:' - }) + body: message, + }) \ No newline at end of file