-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Thomas Weber <[email protected]>
- Loading branch information
1 parent
73ef778
commit 32de315
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
name: Format pull request | ||
|
||
on: | ||
workflow_dispatch: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
|
||
if: | | ||
github.event_name == 'workflow_dispatch' || ( | ||
github.event_name == 'issue_comment' && | ||
github.event.issue.pull_request && | ||
contains(github.event.comment.body, '!format') | ||
) | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
with: | ||
# Credentials needed for pushing changes at the end | ||
persist-credentials: true | ||
- name: Install Node.js | ||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af | ||
with: | ||
node-version: 20.x | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Format | ||
run: npm run format | ||
- name: Commit | ||
run: | | ||
git config --global user.name "$GITHUB_ACTOR" | ||
git config --global user.email "[email protected]" | ||
git stage . | ||
git commit --author "format-pr-bot <[email protected]>" -m "[Automated] Format code" || echo "No changes to commit" | ||
- name: Push | ||
run: git push |