Aiden Cline 2 месяцев назад
Родитель
Сommit
eb4afdca65
2 измененных файлов с 4 добавлено и 2 удалено
  1. 2 1
      .github/workflows/format.yml
  2. 2 1
      script/format.ts

+ 2 - 1
.github/workflows/format.yml

@@ -18,7 +18,6 @@ jobs:
         uses: actions/checkout@v4
         with:
           token: ${{ secrets.GITHUB_TOKEN }}
-          ref: ${{ github.head_ref || github.ref }}
 
       - name: Setup Bun
         uses: ./.github/actions/setup-bun
@@ -28,3 +27,5 @@ jobs:
           ./script/format.ts
         env:
           CI: true
+          GITHUB_HEAD_REF: ${{ github.head_ref }}
+          GITHUB_REF_NAME: ${{ github.ref_name }}

+ 2 - 1
script/format.ts

@@ -5,9 +5,10 @@ import { $ } from "bun"
 await $`bun run prettier --ignore-unknown --write .`
 
 if (process.env["CI"] && (await $`git status --porcelain`.text())) {
+  const branch = process.env["GITHUB_HEAD_REF"] || process.env["GITHUB_REF_NAME"]
   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 --no-verify`
+  await $`git push origin HEAD:${branch} --no-verify`
 }