-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (42 loc) · 1.44 KB
/
auto-format.yaml
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
37
38
39
40
41
42
43
44
45
name: auto-format
on: pull_request
env:
POETRY_VERSION: "1.5.1"
PYTHON_VERSION: "3.11"
jobs:
format:
# Check if the PR is not from a fork
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Get Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: snok/[email protected]
with:
version: ${{ env.POETRY_VERSION }}
- name: Install Linting Dependencies
run: |
make install-lint
- name: Run Formatter
run: |
make format
- name: Check for Modified Files
id: git-check
run: |
git status
echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Push Changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Auto-format Bot'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git commit -am "Automatically reformatting code with black and isort"
git push