-
Notifications
You must be signed in to change notification settings - Fork 32
46 lines (38 loc) · 1.2 KB
/
isort.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
37
38
39
40
41
42
43
44
45
46
name: Code Formatter
# Add 'pull_request:' beneath 'on:' to apply on active PRs
on:
push:
branches:
- main
jobs:
isort:
name: Run Isort
runs-on: ubuntu-latest
# Redundant to determine branch name since workflow only runs on main, but will be useful if we also want the workflow to run PRs
steps:
- name: Determine Branch Name
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
else
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH_NAME }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Run Isort
run: pip install isort==5.13.2 && isort .
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply isort formatting changes
# Ensure Black runs after Isort has completed
black:
needs: isort
uses: ./.github/workflows/black.yml