summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-09-09 23:47:47 -0400
committerDax Raad <[email protected]>2025-09-09 23:47:47 -0400
commite53fb7f8eda760b9d39479a2038720d54a434629 (patch)
tree2cd58463253e72d0331bb88d2b9316f9bcd86997
parentb05cbc910130ed9924f33ece3b5a70885f2f126d (diff)
downloadopencode-e53fb7f8eda760b9d39479a2038720d54a434629.tar.gz
opencode-e53fb7f8eda760b9d39479a2038720d54a434629.zip
ci: format
-rw-r--r--.github/workflows/format.yml29
-rw-r--r--package.json1
-rwxr-xr-xscript/format.ts13
3 files changed, 42 insertions, 1 deletions
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
new file mode 100644
index 000000000..84f82cafc
--- /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 601df5994..78a0e543d 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,6 @@
"packageManager": "[email protected]",
"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 000000000..d80820409
--- /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 "[email protected]"`
+ await $`git config --local user.name "GitHub Action"`
+ await $`git add -A`
+ await $`git commit -m "chore: format code"`
+ await $`git push`
+}