Skip to content

Commit e53fb7f

Browse files
committed
ci: format
1 parent b05cbc9 commit e53fb7f

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.github/workflows/format.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
jobs:
8+
format:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
18+
- name: Setup Bun
19+
uses: oven-sh/setup-bun@v1
20+
with:
21+
bun-version: 1.2.19
22+
23+
- name: Install dependencies
24+
run: bun install
25+
26+
- name: Run format
27+
run: bun run format
28+
env:
29+
CI: true

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"packageManager": "bun@1.2.19",
77
"scripts": {
88
"dev": "bun run --conditions=development packages/opencode/src/index.ts",
9-
"format": "bun run prettier --ignore-unknown --write $(git ls-files)",
109
"typecheck": "bun run --filter='*' typecheck",
1110
"generate": "(cd packages/sdk && ./js/script/generate.ts) && (cd packages/sdk/stainless && ./generate.ts)",
1211
"postinstall": "./script/hooks"

script/format.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bun
2+
3+
import { $ } from "bun"
4+
5+
await $`bun run prettier --ignore-unknown --write $(git ls-files)`
6+
7+
if (process.env["CI"] && (await $`git status --porcelain`.text())) {
8+
await $`git config --local user.email "action@github.com"`
9+
await $`git config --local user.name "GitHub Action"`
10+
await $`git add -A`
11+
await $`git commit -m "chore: format code"`
12+
await $`git push`
13+
}

0 commit comments

Comments
 (0)