# Workflow Actions
Actions are the building blocks of workflow steps. They execute sequentially within a step, with each action's output piped as input to the next.
## Action pipeline
```mermaid
graph LR
A[Action 1] -->|pipe| B[Action 2]
B -->|pipe| C[Action 3]
C -->|pipe| D[output]
```
The pipe is a temporary directory containing the working files. Each action reads from and writes to this directory.
## `import`
Fetches files from a remote source.
```yaml
- import:
source: !github owner/repo # Required
directory: path/in/repo # Optional: subdirectory to extract
reference: main # Optional: branch or tag
```
### Source types
| Type | Syntax | Method |
|------|--------|--------|
| GitHub | `!github owner/repo` | Archive download or git clone |
| GitLab | `!gitlab owner/repo` | Archive download or git clone |
| Git | `!git https://example.com/repo.git` | Git clone |
| Archive | `!archive https://example.com/file.tar.gz` | HTTP download + extract |
When `directory` is specified, only that subdirectory is extracted from the source.
When `reference` is omitted, the repository's default branch is used.
## `local`
References files from the local filesystem.
```yaml
- local:
path: ./relative/path
```
Sets the pipe to point at the specified local directory.
## `template`
Processes files through a template engine.
```yaml
- template:
engine: tera # Required: template engine
glob: '**/*.tf' # Required: file pattern
variables: # Required: template variables
name: MyProject
slug: my-project
env_var: $CI_PROJECT_ID # $ prefix expands env vars
```
Processes matching files in-place using [Tera](https://keats.github.io/tera/) syntax (`{{ variable }}`).
## `copy`
Copies files within the pipe.
```yaml
- copy:
dest: subdirectory # Required: destination within pipe
```
Copies the current pipe contents into a subdirectory.
## `output`
Writes the pipe contents to a final output directory.
```yaml
- output:
path: ./result # Required: output directory
```
If the output directory exists, it is **replaced** entirely.
## `document`
Generates documentation from markdown and YAML data files.
```yaml
- document:
template: template.md # Required: markdown template
data: data.yml # Required: YAML data file
output: README.md # Required: output filename
```
## Example: full pipeline
```yaml
workflow:
- name: Build Terraform module
actions:
- import:
source: !gitlab org/templates/base-module
reference: v2.0.0
- template:
engine: tera
glob: '**/*.tf'
variables:
project_name: my-service
environment: production
- copy:
dest: modules/base
- output:
path: ./generated
```