Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bfe03a5

Browse files
committedApr 17, 2024··
ci(pre-commit): Enforce that the pre-commit checks are run before merge
Change name
1 parent a45b5af commit bfe03a5

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed
 

‎.github/workflows/pre-commit.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Pre-commit check
22

33
on:
44
pull_request:
5-
types: [opened, reopened, synchronize, labeled]
5+
types: [opened, reopened, synchronize, labeled, unlabeled]
66

77
jobs:
88
lint:
@@ -60,3 +60,40 @@ jobs:
6060
if: always()
6161
with:
6262
msg: "ci(pre-commit): Apply automatic fixes"
63+
64+
report-run:
65+
name: Report that the PR is ready for merge
66+
needs: lint
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Report success
70+
if: |
71+
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
72+
uses: actions/github-script@v7
73+
with:
74+
github-token: ${{ secrets.GITHUB_TOKEN }}
75+
script: |
76+
github.rest.repos.createCommitStatus({
77+
owner: context.repo.owner,
78+
repo: context.repo.repo,
79+
sha: context.sha,
80+
state: 'success',
81+
context: 'pre-commit-result',
82+
description: 'All pre-commit checks passed',
83+
});
84+
85+
- name: Report pending
86+
if: |
87+
!contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
88+
uses: actions/github-script@v7
89+
with:
90+
github-token: ${{ secrets.GITHUB_TOKEN }}
91+
script: |
92+
github.rest.repos.createCommitStatus({
93+
owner: context.repo.owner,
94+
repo: context.repo.repo,
95+
sha: context.sha,
96+
state: 'pending',
97+
context: 'pre-commit-result',
98+
description: 'Pre-commit checks need to pass before merging',
99+
});

0 commit comments

Comments
 (0)
Please sign in to comment.