Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slash command "/format" to automatically format PRs #646

Merged
merged 12 commits into from
Oct 24, 2020
40 changes: 40 additions & 0 deletions .github/workflows/format-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: format-command
on:
repository_dispatch:
types: [format-command]
jobs:
format:
runs-on: ubuntu-latest
steps:
# Checkout the pull request branch
- uses: actions/checkout@v2
with:
token: ${{ secrets.PAT }}
seisman marked this conversation as resolved.
Show resolved Hide resolved
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@v1

# Install formatting tools
- name: Install formatting tools
run: pip install black blackdoc flake8

# Run "make format" and commit the change to the PR branch
- name: Commit to the PR branch if any changes
run: |
make format
if [[ $(git ls-files -m) ]]; then
git config --global user.name 'actions-bot'
git config --global user.email '58130806+actions-bot@users.noreply.github.com'
git commit -am "[format-command] fixes"
git push
fi

- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.PAT }}
seisman marked this conversation as resolved.
Show resolved Hide resolved
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: hooray
17 changes: 17 additions & 0 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
# Add "edited" type for test purposes. Where possible, avoid using to prevent processing unnecessary events.
# types: [created, edited]
jobs:
slashCommandDispatch:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v2
with:
token: ${{ secrets.PAT }}
seisman marked this conversation as resolved.
Show resolved Hide resolved
commands: |
format
issue-type: pull-request