---
title: "alpacon-cp-action"
description: "Copy files and directories between local and remote servers in CI/CD workflows. Supports upload, download, recursive copy, multiple source files, and user/group options."
---

> Full documentation index: https://docs.alpacax.com/llms.txt

# alpacon-cp-action

Copy files and directories between your local environment and remote servers in your Alpacon workspace. Supports upload and download modes, recursive directory copy, and multiple source files.

  In v2, the `api-token` input is renamed `service-token`: change `uses: alpacax/alpacon-cp-action@v1` to `uses: alpacax/alpacon-cp-action@v2` and `api-token:` to `service-token:`.

## Inputs

| Name | Description | Required | Default |
|------|-------------|----------|---------|
| `workspace-url` | Alpacon workspace URL | Yes | |
| `service-token` | Alpacon service token key (`alpst-`) | Yes | |
| `source` | Source path(s). Upload: local paths (supports multiple, one per line). Download: single remote path. | Yes | |
| `target-server` | Target server name | Yes | |
| `target-path` | Destination path (remote for upload, local for download) | Yes | |
| `mode` | `upload` or `download` | No | `upload` |
| `recursive` | Copy directories recursively | No | `false` |
| `username` | Username for file ownership on the remote server | No | |
| `groupname` | Group name for file ownership (requires `username`) | No | |

`groupname` cannot be used with a service token: files are transferred with the service account's private group, and a `groupname` value is ignored.

## Usage

### Upload a file

```yaml
- name: Upload config
  uses: alpacax/alpacon-cp-action@v2
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    service-token: ${{ secrets.ALPACON_SERVICE_TOKEN }}
    source: './config.yml'
    target-server: 'prod-server'
    target-path: '/opt/myapp/config.yml'
```

### Upload multiple files

```yaml
- name: Upload multiple files
  uses: alpacax/alpacon-cp-action@v2
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    service-token: ${{ secrets.ALPACON_SERVICE_TOKEN }}
    source: |
      ./docker-compose.yml
      ./nginx.conf
      ./.env.production
    target-server: 'prod-server'
    target-path: '/opt/myapp/'
    username: ubuntu
```

### Upload a directory recursively

```yaml
- name: Upload build artifacts
  uses: alpacax/alpacon-cp-action@v2
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    service-token: ${{ secrets.ALPACON_SERVICE_TOKEN }}
    source: './dist/'
    target-server: 'prod-server'
    target-path: '/var/www/app/'
    recursive: true
```

### Download a file

```yaml
- name: Download logs
  uses: alpacax/alpacon-cp-action@v2
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    service-token: ${{ secrets.ALPACON_SERVICE_TOKEN }}
    source: '/var/log/app/error.log'
    target-server: 'prod-server'
    target-path: './logs/'
    mode: download
```

## Notes

- Requires [`alpacon-setup-action`](/reference/actions/setup/) to run first
- **Upload `target-path`**: can be a file path or directory path
- **Download `target-path`**: must be a directory path—the file is saved with its original filename
- **Multiple sources**: only supported in upload mode (one path per line)
- **Download mode**: supports only a single source path
- `groupname` requires `username` to be set

## See also

- [Actions reference overview](/reference/actions/)
- [alpacon-setup-action](/reference/actions/setup/)
- [alpacon-exec-action](/reference/actions/exec/)
- [alpacon-common-action](/reference/actions/common/)

## Resources

- [GitHub Marketplace](https://github.com/marketplace/actions/alpacon-cp-action)
- [Source code](https://github.com/alpacax/alpacon-cp-action)
- [CLI reference: alpacon cp](/reference/cli/cp/)

Source: https://docs.alpacax.com/reference/actions/cp/
