// Create an ephemeral branch off of "main"
const preview = await repo
.createCommit({
targetBranch: 'preview/pr-123',
baseBranch: 'main',
ephemeral: true, // Keep the branch in the ephemeral namespace
commitMessage: 'Preview environment for PR 123',
author: { name: 'CI Bot', email: '[email protected]' },
})
.addFileFromString('index.html', '<h1>Preview</h1>')
.send();
// Access content from the ephemeral branch
const response = await repo.getFileStream({
path: 'index.html',
ref: 'preview/pr-123',
ephemeral: true, // Read from the ephemeral namespace
});
const html = await response.text();
console.log(html);
// List files that live under the ephemeral branch
const files = await repo.listFiles({
ref: 'preview/pr-123',
ephemeral: true,
});
console.log(files.paths);