Skip to content

Commit bad6eae

Browse files
committed
Test
1 parent 4070a87 commit bad6eae

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

.github/workflows/pre-commit-status.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Report Pre-commit Check Status
1+
name: Run Pre-commit Checks
22

33
on:
44
pull_request_target:
@@ -8,8 +8,8 @@ permissions:
88
statuses: write
99

1010
jobs:
11-
report-run:
12-
name: Check if the PR has run the pre-commit checks
11+
report-pending:
12+
name: Report pre-commit workflow as pending
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Report pending
@@ -19,22 +19,30 @@ jobs:
1919
state: pending
2020
description: The pre-commit checks need to be successful before merging
2121

22-
- name: Wait for pre-commit checks to complete
23-
uses: lucasssvaz/wait-on-workflow@v1
24-
if: |
25-
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
26-
id: wait-on-workflow
22+
run-pre-commit:
23+
name: Run pre-commit checks
24+
needs: report-pending
25+
if: |
26+
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
27+
uses: ./.github/workflows/pre-commit.yml
28+
secrets: inherit
29+
30+
report-success:
31+
name: Push changes and report success
32+
needs: run-pre-commit
33+
runs-on: ubuntu-latest
34+
if: |
35+
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') &&
36+
needs.run-pre-commit.result == 'success'
37+
steps:
38+
- name: Push changes using pre-commit-ci-lite
39+
uses: lucasssvaz/lite-action@main
2740
with:
28-
timeout: 10
29-
interval: 30
30-
workflow: pre-commit.yml
31-
sha: ${{ github.event.pull_request.head.sha || github.sha }}
41+
msg: "ci(pre-commit): Apply automatic fixes"
42+
run: ${{ needs.run-pre-commit.outputs.run-id }}
3243

3344
- name: Report success
3445
uses: conda/actions/[email protected]
35-
if: |
36-
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') &&
37-
steps.wait-on-workflow.outputs.conclusion == 'success'
3846
with:
3947
context: "Pre-commit checks"
4048
state: success

.github/workflows/pre-commit.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
name: Pre-commit hooks
22

33
on:
4-
pull_request:
5-
types: [opened, reopened, synchronize, labeled, unlabeled]
4+
workflow_dispatch:
5+
workflow_call:
6+
outputs:
7+
run-id:
8+
description: "The pre-commit checks run id"
9+
value: ${{ github.run_id }}
10+
push: # To generate cache for other branches
11+
branches:
12+
- master
613

714
jobs:
815
lint:
9-
if: |
10-
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
1116
name: Check if fixes are needed
1217
runs-on: ubuntu-latest
1318
steps:
@@ -55,8 +60,3 @@ jobs:
5560
~/.cache/pip
5661
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
5762

58-
- name: Push changes using pre-commit-ci-lite
59-
uses: pre-commit-ci/[email protected]
60-
if: always()
61-
with:
62-
msg: "ci(pre-commit): Apply automatic fixes"

0 commit comments

Comments
 (0)