-
Notifications
You must be signed in to change notification settings - Fork 50
36 lines (35 loc) · 1.43 KB
/
autofix.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
on:
pull_request_target:
jobs:
autofix:
runs-on: ubuntu-latest
steps:
# git-auto-commit-action is a bit tricky to use.
# See the "advanced" section in its README for an insecure configuration that works.
#
# To make it secure against malicious pull requests, you cannot trust files in the PR,
# because pull_request_target jobs have more permissions than pull_request jobs.
# Here we place the PR's stuff to a subdirectory named "pr".
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
path: ./pr
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
- run: pip install wheel
- run: pip install -r requirements-dev.txt
- name: Gather a list of Python files in the pull request branch
run: |
(cd pr && git ls-files) | grep -E '\.(py|pyw)$' | sed s:^:pr/: | tee filelist.txt
- run: python3 -m pycln --all --disable-all-dunder-policy $(cat filelist.txt)
- run: python3 -m pyupgrade $(cat filelist.txt) --keep-runtime-typing --py38-plus --exit-zero-even-if-changed
- run: python3 -m black $(cat filelist.txt)
- run: python3 -m isort $(cat filelist.txt)
- uses: stefanzweifel/git-auto-commit-action@v4
with:
repository: ./pr
commit_message: "Run pycln, pyupgrade, black and isort"