@@ -2,7 +2,10 @@ name: Pre-commit check
22
33on :
44 pull_request :
5- types : [opened, reopened, synchronize, labeled]
5+ types : [opened, reopened, synchronize, labeled, unlabeled]
6+
7+ permissions :
8+ statuses : write
69
710jobs :
811 lint :
6063 if : always()
6164 with :
6265 msg : " ci(pre-commit): Apply automatic fixes"
66+
67+ report-run :
68+ name : Check if the PR has run the pre-commit checks
69+ needs : lint
70+ if : always()
71+ runs-on : ubuntu-latest
72+ steps :
73+ - name : Report success
74+ if : |
75+ contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') &&
76+ needs.lint.result == 'success'
77+ uses : actions/github-script@v7
78+ with :
79+ script : |
80+ github.rest.repos.createCommitStatus({
81+ owner: context.repo.owner,
82+ repo: context.repo.repo,
83+ sha: ${{ github.event.pull_request.head.sha }},
84+ state: 'success',
85+ context: 'pre-commit-result',
86+ description: 'All pre-commit checks passed',
87+ });
88+
89+ - name : Report pending
90+ env :
91+ GH_TOKEN : ${{ github.token }}
92+ if : |
93+ !contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') ||
94+ needs.lint.result == 'failure'
95+ run : |
96+ gh api \
97+ --method POST \
98+ -H "Accept: application/vnd.github+json" \
99+ -H "X-GitHub-Api-Version: 2022-11-28" \
100+ /repos/${{ github.repository }}/statuses/${{ github.sha }} \
101+ -f state=pending -f context=pre-commit-result -f description="Pre-commit checks need to pass before merging"
0 commit comments