-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (67 loc) · 2.43 KB
/
format.yml
File metadata and controls
81 lines (67 loc) · 2.43 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: "Python Black Formatter"
on:
pull_request:
types: [ opened ]
issue_comment:
types: [ created ]
permissions:
contents: write
jobs:
format:
name: "Format"
runs-on: ubuntu-22.04
if: github.event.issue.pull_request
steps:
- uses: khan/pull-request-comment-trigger@edab8d9ba7759221187ef7120592a6fbfada0d18 # pin@v1.1.0
id: check
with:
trigger: '/format'
reaction: "+1" # Reaction must be one of the reactions here: https://developer.github.com/v3/reactions/#reaction-types
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3
if: steps.check.outputs.triggered == 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check out PR
if: steps.check.outputs.triggered == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.issue.number }}
- name: Set up Python
uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # pin@v3
if: steps.check.outputs.triggered == 'true'
with:
python-version: "3.10"
cache: "pip"
- name: Install
if: steps.check.outputs.triggered == 'true'
run: pip install black isort
- name: Format using black
uses: psf/black@193ee766ca496871f93621d6b58d57a6564ff81b # pin@stable
if: steps.check.outputs.triggered == 'true'
with:
options: "--verbose"
- name: Sort imports using isort
if: steps.check.outputs.triggered == 'true'
run: isort --verbose .
- name: Commit changes
if: steps.check.outputs.triggered == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git status
git diff --stat
git commit -am "chore: format code"
git log --oneline --max-count=10
git push
- uses: khan/pull-request-comment-trigger@edab8d9ba7759221187ef7120592a6fbfada0d18 # pin@v1.1.0
if: failure()
with:
trigger: '/format'
reaction: "confused" # Reaction must be one of the reactions here: https://developer.github.com/v3/reactions/#reaction-types
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}