-
Notifications
You must be signed in to change notification settings - Fork 235
Add slash command "/format" to automatically format PRs #646
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8ba90b9
Add slash command "/format" (#1)
seisman 7a29620
Fix output of "make check" (#3)
seisman 9837239
format-command: set continue-on-error to true for the style checking …
seisman fd7156e
Debug the output of an action
seisman 778378f
Always format and commit changes if any
seisman 488dee6
Fix checking of changed files
seisman 189921c
Apply suggestions from code review
seisman c3feb6b
Update .github/workflows/slash-command-dispatch.yml
seisman 11b45b3
Explain "/format" in the pull request template
seisman 908f068
Explain "/format" in the CONTRIBUTING guide
seisman c74e68a
Apply suggestions from code review
seisman 938f013
Merge remote-tracking branch 'upstream/master'
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: format-command | ||
| on: | ||
| repository_dispatch: | ||
| types: [format-command] | ||
| jobs: | ||
| format: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # Generate token from GenericMappingTools bot | ||
| - uses: tibdex/github-app-token@v1 | ||
| id: generate-token | ||
| with: | ||
| app_id: ${{ secrets.APP_ID }} | ||
| private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
|
||
| # Checkout the pull request branch | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| token: ${{ steps.generate-token.outputs.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@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 '[email protected]' | ||
| git commit -am "[format-command] fixes" | ||
| git push | ||
| fi | ||
|
|
||
| - name: Add reaction | ||
| uses: peter-evans/create-or-update-comment@v1 | ||
| with: | ||
| token: ${{ steps.generate-token.outputs.token }} | ||
| repository: ${{ github.event.client_payload.github.payload.repository.full_name }} | ||
| comment-id: ${{ github.event.client_payload.github.payload.comment.id }} | ||
| reaction-type: hooray |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | ||
| commands: | | ||
| format | ||
| issue-type: pull-request | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.