Skip to content

Commit

Permalink
Add formatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Nov 6, 2024
1 parent cd5ea7a commit f29900e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
63 changes: 63 additions & 0 deletions .github/workflows/formatbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Format PR

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
format:
name: Format code
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

steps:
- name: Determine if fork
id: check_fork
run: |
if [ "${{ github.event.pull_request.head.repo.full_name }}" = "${{ github.repository }}" ]; then
echo "is_fork=false" >> $GITHUB_OUTPUT
else
echo "is_fork=true" >> $GITHUB_OUTPUT
fi
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ steps.check_fork.outputs.is_fork == 'true' && secrets.GITHUB_TOKEN || secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}

- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Get @biomejs/biome version
id: get-biome-version
run: echo "BIOME_VERSION=$(node -p "require('./package.json').devDependencies['@biomejs/biome']")" >> $GITHUB_OUTPUT

- name: Install @biomejs/biome
run: bun install @biomejs/biome@${{ steps.get-biome-version.outputs.BIOME_VERSION }}

- name: Run Formatter and autofix
if: steps.check_fork.outputs.is_fork == 'false'
run: biome format . --write

- name: Format Check (cannot autofix against forks)
if: steps.check_fork.outputs.is_fork == 'true'
run: biome format .

- name: Restore lock files
if: steps.check_fork.outputs.is_fork == 'false'
run: |
git checkout -- *lock.json || true
git checkout -- *.lock || true
git checkout -- *.lockb || true
- name: Commit changes
if: steps.check_fork.outputs.is_fork == 'false'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "formatbot: Automatically format code"
branch: ${{ github.head_ref }}
commit_user_name: tscircuitbot
commit_user_email: [email protected]
commit_author: tscircuitbot <[email protected]>
2 changes: 1 addition & 1 deletion lib/hooks/use-diode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { createUseComponent } from "./create-use-component"
export const useDiode = createUseComponent(
(props: DiodeProps) => <diode {...props} />,
diodePins,
)
)

0 comments on commit f29900e

Please sign in to comment.