Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci-autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
11 changes: 10 additions & 1 deletion internal/publish/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/publish/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Loading