From b711d63a10c7ca487ff2bb5b911c2035a15df1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Guid=C3=A9e?= Date: Sun, 29 Nov 2020 21:50:04 +0100 Subject: [PATCH] [.github/workflows] PEP8 Checker action --- .github/workflows/pep8.yml | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/pep8.yml diff --git a/.github/workflows/pep8.yml b/.github/workflows/pep8.yml new file mode 100644 index 0000000..81acc69 --- /dev/null +++ b/.github/workflows/pep8.yml @@ -0,0 +1,54 @@ +# By @quentinguidee, licenced under the MIT license. + +name: PEP8 check + +on: [pull_request_target] + +jobs: + run: + 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 }} + 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) + uses: actions/github-script@v3 + env: + OUTPUT: ${{ steps.run_pycodestyle.outputs.pycodestyle }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + 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:' + })