@@ -200,23 +200,32 @@ jobs:
200200 runs-on : ubuntu-latest
201201 steps :
202202 - uses : actions/checkout@v4
203- - name : Check files using the black formatter
203+ - name : Check Python formatting with black
204204 uses : rickstaa/action-black@v1
205205 id : action_black
206206 with :
207207 black_args : " ."
208- - name : Create Pull Request
209- if : steps.action_black.outputs.is_formatted == 'true'
210- uses : peter-evans/create-pull-request@v6
208+ fail_on_error : false # Don't fail, we'll handle it
209+
210+ - name : Comment on PR if formatting needed
211+ if : steps.action_black.outputs.is_formatted == 'true' && github.event_name == 'pull_request'
212+ uses : actions/github-script@v7
211213 with :
212- token : ${{ secrets.GITHUB_TOKEN }}
213- title : " Format Python code with psf/black push"
214- commit-message : " :art: Format Python code with psf/black"
215- body : |
216- There appear to be some python formatting errors in ${{ github.sha }}. This pull request
217- uses the [psf/black](https://github.com/psf/black) formatter to fix these issues.
218- base : ${{ github.head_ref }} # Creates pull request onto pull request or commit branch
219- # branch: actions/black
214+ script : |
215+ github.rest.issues.createComment({
216+ issue_number: context.issue.number,
217+ owner: context.repo.owner,
218+ repo: context.repo.repo,
219+ body: '⚠️ **Code formatting issue detected**\n\n' +
220+ 'This PR contains Python code that doesn\'t conform to the [Black](https://github.com/psf/black) formatting standard.\n\n' +
221+ 'Please run `black .` locally and commit the changes, or use the "Auto-fix formatting" workflow if available.'
222+ })
223+
224+ - name : Fail CI if formatting issues found
225+ if : steps.action_black.outputs.is_formatted == 'true'
226+ run : |
227+ echo "❌ Code formatting issues detected. Please run 'black .' to fix."
228+ exit 1
220229
221230 test-installation :
222231 name : Test Package Installation
0 commit comments