Alpacon Exec Action

Alpacon Exec Action runs shell commands on remote servers in your workspace. It runs each line of your script as a separate alpacon exec command. You can choose a server account and pass environment variables.

Note

Update uses: alpacax/alpacon-websh-action@v1 to uses: alpacax/alpacon-exec-action@v2, and rename the api-token input to service-token. GitHub does not redirect uses: references when an action repository is renamed, so workflows using the old name fail with repository not found.

Inputs

NameDescriptionRequiredDefault
workspace-urlAlpacon workspace URLYes
service-tokenAlpacon service token key (alpst-)Yes
targetTarget server nameYes
scriptShell command or script to executeYes
usernameThe application’s server account to run the command asNo
groupnameGroup override (ignored for a service token; the command runs in the service account’s private group)No
envEnvironment variables (one per line, KEY=VALUE or KEY format)No

Usage

Basic command execution

yaml
- name: Deploy application
  uses: alpacax/alpacon-exec-action@v2
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    service-token: ${{ secrets.ALPACON_SERVICE_TOKEN }}
    target: 'prod-server'
    username: 'ci-deploy'
    script: |
      cd /opt/myapp && git pull && npm install && pm2 restart app

Execute as the application account

yaml
- name: Copy files as the application account
  uses: alpacax/alpacon-exec-action@v2
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    service-token: ${{ secrets.ALPACON_SERVICE_TOKEN }}
    target: 'web-server'
    username: 'ci-deploy'
    script: cp -r /tmp/build/. /home/ci-deploy/app/public/

Pass environment variables

yaml
- name: Run with environment variables
  uses: alpacax/alpacon-exec-action@v2
  with:
    workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }}
    service-token: ${{ secrets.ALPACON_SERVICE_TOKEN }}
    target: 'prod-server'
    username: 'ci-deploy'
    env: |
      APP_ENV=production
      DB_HOST=localhost
      LOG_LEVEL=info
    script: |
      echo "Deploying to $APP_ENV"
      sudo 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
  • Keep dependent shell operations on one line, such as cd /opt/myapp && git pull
  • Empty lines and comment-only lines (starting with #) are skipped
  • groupname is ignored for a service token: the command runs in the service account’s private group
  • The system-service example needs the sudo settings and command rule

See also

Resources

Last updated: