fix: Telegram PR merge notification #354
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Format python code with autopep8 | |
on: pull_request | |
jobs: | |
autopep8: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: autopep8 | |
id: autopep8 | |
uses: peter-evans/autopep8@v2 | |
with: | |
args: --exit-code --max-line-length 120 --recursive --in-place --aggressive --aggressive . | |
- name: Find Comment | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
- name: Create comment if autopep8 made NO changes | |
if: ${{ steps.fc.outputs.comment-id == '' && steps.autopep8.outputs.exit-code != 2}} | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Code has no PEP8 errors! | |
- name: Create comment if autopep8 made changes | |
if: ${{ steps.fc.outputs.comment-id == '' && steps.autopep8.outputs.exit-code == 2}} | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Code in this pull request contains PEP8 errors, please write the `/fix-pep8` command in the comments below to create commit with automatic fixes. | |
- name: Retrieve current Date & Time in Moscow TimeZone | |
shell: bash | |
run: echo "TIMESTAMP=$(TZ=":Europe/Moscow" date -R|sed 's/.....$//')" >> $GITHUB_ENV | |
- name: Update comment if NOT fixed | |
if: ${{ steps.fc.outputs.comment-id != '' && steps.autopep8.outputs.exit-code == 2}} | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
edit-mode: replace | |
body: | | |
Code in this pull request **still** contains PEP8 errors, please write the `/fix-pep8` command in the comments below to create commit with automatic fixes. | |
##### Comment last updated at ${{ env.TIMESTAMP }} | |
- name: Update comment if fixed | |
if: ${{ steps.fc.outputs.comment-id != '' && steps.autopep8.outputs.exit-code != 2}} | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
edit-mode: replace | |
body: | | |
All PEP8 errors has been fixed, thanks :heart: | |
##### Comment last updated at ${{ env.TIMESTAMP }} | |
- name: Fail if autopep8 made changes | |
if: steps.autopep8.outputs.exit-code == 2 | |
run: exit 1 |