Skip to content

black-command

black-command #32

Workflow file for this run

name: black-command
on:
repository_dispatch:
types: [black-command]
jobs:
black:
runs-on: ubuntu-latest
steps:
# Checkout the pull request branch
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
# Setup Python environment
- uses: actions/setup-python@v4
# Install black
- name: Install black
run: pip install black
# Execute black in check mode
- name: Black
id: black
run: |
format=$(black --check --quiet . || echo "true")
echo "format=$format" >> $GITHUB_OUTPUT
# Execute black and commit the change to the PR branch
- name: Commit to the PR branch
if: steps.black.outputs.format == 'true'
run: |
black .
git config --global user.name 'actions-bot'
git config --global user.email '[email protected]'
git commit -am "[black-command] fixes"
git push
- name: Add reaction
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: hooray