diff --git a/.github/workflows/ci-autofix.yml b/.github/workflows/ci-autofix.yml index ca8b75f..105b78a 100644 --- a/.github/workflows/ci-autofix.yml +++ b/.github/workflows/ci-autofix.yml @@ -24,7 +24,9 @@ jobs: - name: Checkout failed branch uses: actions/checkout@v4 with: + repository: ${{ github.event.workflow_run.head_repository.full_name }} ref: ${{ github.event.workflow_run.head_branch }} + fetch-depth: 0 - name: Stop on stale branch head id: freshness @@ -79,7 +81,10 @@ jobs: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add -A git commit -m "ci: auto-fix formatting and lint" - git push origin HEAD:${{ github.event.workflow_run.head_branch }} + branch="${{ github.event.workflow_run.head_branch }}" + git fetch origin "${branch}" + git pull --rebase origin "${branch}" + git push origin HEAD:"${branch}" - name: Re-dispatch CI if: steps.changes.outputs.changed == 'true' diff --git a/internal/publish/publish.go b/internal/publish/publish.go index 9c75ae0..a64e887 100644 --- a/internal/publish/publish.go +++ b/internal/publish/publish.go @@ -343,7 +343,7 @@ Not-tested: Remote release workflow execution if err := os.WriteFile(messagePath, []byte(message), 0o644); err != nil { return fmt.Errorf("writing git commit message: %w", err) } - return runGit(sourceDir, "commit", "-F", messagePath) + return runGitCommit(sourceDir, messagePath) } func runGit(dir string, args ...string) error { @@ -356,6 +356,15 @@ func runGit(dir string, args ...string) error { return nil } +func runGitCommit(dir, messagePath string) error { + args := []string{ + "-c", "user.name=climate", + "-c", "user.email=climate@users.noreply.github.com", + "commit", "-F", messagePath, + } + return runGit(dir, args...) +} + // PublishedManifestEntry returns a manifest entry updated with repository metadata. func PublishedManifestEntry(entry manifest.CLIEntry, result *Result) manifest.CLIEntry { entry.RepositoryURL = result.RepositoryURL diff --git a/internal/publish/publish_test.go b/internal/publish/publish_test.go index 3d02672..b81a408 100644 --- a/internal/publish/publish_test.go +++ b/internal/publish/publish_test.go @@ -91,7 +91,7 @@ func TestSyncGitRepositoryExistingRepoPreservesRemoteFiles(t *testing.T) { } verifyDir := t.TempDir() - if err := runGit("", "clone", remoteBare, verifyDir); err != nil { + if err := runGit("", "clone", "--branch", "main", remoteBare, verifyDir); err != nil { t.Fatalf("clone verify repo: %v", err) } readme, err := os.ReadFile(filepath.Join(verifyDir, "README.md"))