Files workspace
The files workspace is the panel on the right side of the Runbooks window, labeled Files. It shows two types of files:
- Generated files are new files the runbook creates. Use them when the user will do something with the files outside the runbook, such as copying them into another project.
- Repository files are a git repository the runbook cloned. Use them when later blocks create, modify, or delete files in that repo, usually before pushing the changes or opening a pull request.
Drag the divider between the runbook and the workspace to change how wide each one is. Double-click the divider to put back the default widths.
Generated files
Section titled “Generated files”There are two ways a runbook generates files. The workspace opens automatically when either one produces a file.
Template blocks
Section titled “Template blocks”The Template and TemplateInline blocks generate files from Boilerplate templates. A Template renders its files when you fill in its form and click Generate. A TemplateInline has no form: with generateFile={true}, it writes its file once every input it uses has a value. The default target is "generated".
<Template id="vpc-setup" path="templates/vpc" />Template blocks re-render when you change input values, so the generated files match the form.
Command and Check blocks with $GENERATED_FILES
Section titled “Command and Check blocks with $GENERATED_FILES”Scripts run by Command, Check and Finish blocks can write files to the directory named by the $GENERATED_FILES environment variable:
<Command id="export-tofu" command={`tofu output -json > "$GENERATED_FILES/tofu-outputs.json"`} title="Export OpenTofu outputs"/>Files written to $GENERATED_FILES appear in the workspace when the script exits with code 0 or 2.
Reviewing changed files
Section titled “Reviewing changed files”The workspace highlights each generated file that changed since you last reviewed it. A Template you have already generated renders again when you change an input, so the highlights show what that change did to the files.
- In the file tree, a file marked A was added and a file marked M was modified. A dot next to a folder means a file inside it changed.
- In the code, the file has a colored border and an Added or Modified label with its count of added and removed lines. The changed lines are highlighted, and a red line marks where lines were removed.
- The header above the files shows how many changed.
Click a modified file in the tree to jump to its first change. It stays highlighted while it’s selected, and counts as reviewed once you select another file. Changes to the file while it’s selected, such as a Template rendering again as you edit its form, show up in its highlights as they happen and count as reviewed with the rest. Scrolling down past a file’s changes also counts as reviewing it: once its last changed line, or the end of a file that was added, goes past the top of the workspace. While files are left to review, there’s room below the last file to scroll it past the top too. Only your own scrolling counts, not a jump to a file you clicked in the tree, and a collapsed file isn’t reviewed until you expand it. To stop highlighting a file without scrolling past it, click Dismiss on the file, or Dismiss all in the header.
Which files are left to review is saved with the session, so a resumed session still highlights them.
Where generated files are stored
Section titled “Where generated files are stored”Runbooks writes generated files to a generated/ folder inside the runbook’s session directory, which Runbooks keeps in its own data folder. Nothing is written to the folder that contains the runbook file. Template blocks and $GENERATED_FILES captures both write there, even after a script has cd’d somewhere else:
Directorysessions/dirs/
Directory0199a5c2-7e3b-7c4d-9a1f-3b2c4d5e6f70/ The runbook’s session directory
Directorygenerated/
- main.tf
- variables.tf
- outputs.tf
The files workspace shows the folder as ./generated, and the copy button next to it copies the full path. Opening the runbook again resumes the same session, so the files are still there. This holds for a remote runbook too: only its clone is temporary.
Subdirectories
Section titled “Subdirectories”A script that writes to a subdirectory of $GENERATED_FILES creates the subdirectory itself:
mkdir -p "$GENERATED_FILES/config"echo '{}' > "$GENERATED_FILES/config/app.json"Directorygenerated
Directoryconfig/
- app.json
- main.tf
- variables.tf
- outputs.tf
Repository files
Section titled “Repository files”Repository files come from a git repository that a GitClone block cloned, or from a local checkout the user selected in one. When the clone completes, the workspace switches to the Repository tab.
The clone is stored at the local path set in the GitClone block, relative to the working directory. The working directory starts as the runbook’s session directory, and it follows any cd that an earlier script made.
Later changes to the repository come from a Template or TemplateInline block that sets target="worktree", or from Command, Check and Finish scripts that write to the directory named by $REPO_FILES.
The Repository tab has two sub-tabs.
All files
Section titled “All files”The All files tab shows the complete file tree of the cloned repository. Click any file to view its contents with syntax highlighting.
Changed files
Section titled “Changed files”The Changed files tab shows a diff of the files that changed since the repository was cloned:
- Which files were added, modified, or deleted
- Line-by-line additions and deletions
- A summary of total changes at the top
Multiple repositories
Section titled “Multiple repositories”If a runbook’s <GitClone> blocks add more than one repository, a dropdown at the top of the Repository tab replaces the repository and branch name and switches between them. The selected repository is the one $REPO_FILES points to, that target="worktree" writes to, and that a GitPullRequest block works on. Until the user selects another, it’s the first one added, whether by a clone or a local checkout.
Where Runbooks reads and writes files
Section titled “Where Runbooks reads and writes files”Runbooks checks each path a block asks it to read or write. It resolves symlinks first, then allows the path only when it is inside one of these:
- the working directory
- the folder that contains the runbook
- a repository registered by a GitClone block
This covers the template folder a Template block reads, the folder Template and TemplateInline blocks write to, the directories a DirPicker lists, and the file tree, file contents, and git changes shown in the workspace. A symlink inside an allowed folder that points outside it is rejected.
A GitClone destination has a stricter rule, because cloning can delete what is already there. It must be a subdirectory of the working directory, and it must not contain the open runbook.
Next, read about the use cases for Runbooks.