-
Notifications
You must be signed in to change notification settings - Fork 14
53 lines (43 loc) · 1.8 KB
/
Copy pathmaintenance.yml
File metadata and controls
53 lines (43 loc) · 1.8 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
name: maintenance
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
maintenance:
runs-on: ubuntu-latest
steps:
- name: Checkout pull request branch
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Checkout
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pre-commit
run: python -m pip install pre-commit
# Same-repo branches (push / non-fork PR): auto-fix and commit back.
- name: Run pre-commit
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
continue-on-error: true
run: pre-commit run --all-files --show-diff-on-failure
- name: Commit maintenance fixes
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: maintenance"
- name: Verify pre-commit
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
run: pre-commit run --all-files --show-diff-on-failure
# Fork PRs are read-only: check and fail with diffs, never push back.
- name: Run pre-commit for external pull requests
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
run: pre-commit run --all-files --show-diff-on-failure