From e53fb7f8eda760b9d39479a2038720d54a434629 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Tue, 9 Sep 2025 23:47:47 -0400 Subject: [PATCH] ci: format --- .github/workflows/format.yml | 29 +++++++++++++++++++++++++++++ package.json | 1 - script/format.ts | 13 +++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/format.yml create mode 100755 script/format.ts diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..84f82caf --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,29 @@ +name: Format + +on: + push: + pull_request: + workflow_dispatch: +jobs: + format: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.2.19 + + - name: Install dependencies + run: bun install + + - name: Run format + run: bun run format + env: + CI: true diff --git a/package.json b/package.json index 601df599..78a0e543 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "packageManager": "bun@1.2.19", "scripts": { "dev": "bun run --conditions=development packages/opencode/src/index.ts", - "format": "bun run prettier --ignore-unknown --write $(git ls-files)", "typecheck": "bun run --filter='*' typecheck", "generate": "(cd packages/sdk && ./js/script/generate.ts) && (cd packages/sdk/stainless && ./generate.ts)", "postinstall": "./script/hooks" diff --git a/script/format.ts b/script/format.ts new file mode 100755 index 00000000..d8082040 --- /dev/null +++ b/script/format.ts @@ -0,0 +1,13 @@ +#!/usr/bin/env bun + +import { $ } from "bun" + +await $`bun run prettier --ignore-unknown --write $(git ls-files)` + +if (process.env["CI"] && (await $`git status --porcelain`.text())) { + await $`git config --local user.email "action@github.com"` + await $`git config --local user.name "GitHub Action"` + await $`git add -A` + await $`git commit -m "chore: format code"` + await $`git push` +}