ci: format
This commit is contained in:
29
.github/workflows/format.yml
vendored
Normal file
29
.github/workflows/format.yml
vendored
Normal file
@@ -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
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
"packageManager": "bun@1.2.19",
|
"packageManager": "bun@1.2.19",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --conditions=development packages/opencode/src/index.ts",
|
"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",
|
"typecheck": "bun run --filter='*' typecheck",
|
||||||
"generate": "(cd packages/sdk && ./js/script/generate.ts) && (cd packages/sdk/stainless && ./generate.ts)",
|
"generate": "(cd packages/sdk && ./js/script/generate.ts) && (cd packages/sdk/stainless && ./generate.ts)",
|
||||||
"postinstall": "./script/hooks"
|
"postinstall": "./script/hooks"
|
||||||
|
|||||||
13
script/format.ts
Executable file
13
script/format.ts
Executable file
@@ -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`
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user