// Create an ephemeral branch from "main".
builder, err := repo.CreateCommit(storage.CommitOptions{
TargetBranch: "preview/pr-123",
BaseBranch: "main",
Ephemeral: true,
CommitMessage: "Preview environment for PR 123",
Author: storage.CommitSignature{Name: "CI Bot", Email: "ci@example.com"},
})
_, err = builder.AddFileFromString("index.html", "<h1>Preview</h1>", nil).Send(context.Background())
// Read a file from the ephemeral branch.
ephemeral := true
resp, err := repo.FileStream(context.Background(), storage.GetFileOptions{
Path: "index.html",
Ref: "preview/pr-123",
Ephemeral: &ephemeral,
})
defer resp.Body.Close()
// List files in the ephemeral branch.
files, err := repo.ListFiles(context.Background(), storage.ListFilesOptions{
Ref: "preview/pr-123",
Ephemeral: &ephemeral,
})
fmt.Println(files.Paths)