Skip to content

Commit 12e3682

Browse files
authored
Add autopep8 github action
1 parent 37d2c3b commit 12e3682

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/autopep8.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: autopep8
2+
on: pull_request
3+
jobs:
4+
autopep8:
5+
# Check if the PR is not raised by this workflow and is not from a fork
6+
if: startsWith(github.head_ref, 'autopep8-patches') == false && github.event.pull_request.head.repo.full_name == github.repository
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Set up Python 3
10+
uses: actions/setup-python@v2
11+
with:
12+
python-version: 3
13+
- name: Checkout Code
14+
uses: actions/checkout@v2
15+
with:
16+
ref: ${{ github.head_ref }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install setuptools wheel flake8 pytest
21+
- name: autopep8
22+
id: autopep8
23+
uses: peter-evans/autopep8@v1
24+
with:
25+
args: --exit-code --recursive --in-place --aggressive --aggressive .
26+
- name: Set autopep8 branch name
27+
id: vars
28+
run: echo ::set-output name=branch-name::"autopep8-patches/$GITHUB_HEAD_REF"
29+
- name: Create Pull Request
30+
if: steps.autopep8.outputs.exit-code == 2
31+
uses: peter-evans/create-pull-request@v2
32+
with:
33+
commit-message: autopep8 action fixes
34+
committer: Carmine Scarpitta <[email protected]>
35+
title: Fixes by autopep8 action
36+
body: This is an auto-generated PR with fixes by autopep8.
37+
labels: autopep8, automated pr
38+
reviewers: cscarpitta
39+
branch: ${{ steps.vars.outputs.branch-name }}
40+
- name: Fail if autopep8 made changes
41+
if: steps.autopep8.outputs.exit-code == 2
42+
run: exit 1

0 commit comments

Comments
 (0)