alpacon-websh-action

Execute shell commands on remote servers in your Alpacon workspace. Supports running commands as specific users and groups, passing environment variables, and multi-line scripts.

Inputs

NameDescriptionRequiredDefault
workspace-urlAlpacon workspace URLYes
api-tokenAlpacon API tokenYes
targetTarget server nameYes
scriptShell command or script to executeYes
usernameUsername to execute the command as (e.g., root, ubuntu)No
groupnameGroup name to execute the command as (requires username)No
envEnvironment variables (one per line, KEY=VALUE or KEY format)No

Usage

Basic command execution

- name: Deploy application
  uses: alpacax/alpacon-websh-action@v1
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    api-token: ${{ secrets.ALPACON_API_TOKEN }}
    target: 'prod-server'
    script: |
      cd /opt/myapp
      git pull
      npm install
      pm2 restart app

Execute as specific user and group

- name: Deploy with www-data group
  uses: alpacax/alpacon-websh-action@v1
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    api-token: ${{ secrets.ALPACON_API_TOKEN }}
    target: 'web-server'
    username: 'ubuntu'
    groupname: 'www-data'
    script: cp -r /tmp/build/* /var/www/html/

Pass environment variables

- name: Run with environment variables
  uses: alpacax/alpacon-websh-action@v1
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    api-token: ${{ secrets.ALPACON_API_TOKEN }}
    target: 'prod-server'
    env: |
      APP_ENV=production
      DB_HOST=localhost
      LOG_LEVEL=info
    script: |
      echo "Deploying to $APP_ENV"
      systemctl restart myapp

The env input supports two formats:

  • KEY=VALUE: sets the variable to the specified value
  • KEY: forwards the variable from the runner environment

Notes

  • Requires alpacon-setup-action to run first
  • Each line in script is executed as a separate command
  • Empty lines and comment-only lines (starting with #) are skipped
  • groupname requires username to be set

See also

Resources