Skip to content

GitHub Action

Use albertoarena/laravel-netsons-deploy@v1 as a reusable composite action in your workflow.

Basic Usage

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# ... your build steps (PHP, Node, assets) ...
- uses: albertoarena/laravel-netsons-deploy@v1
with:
strategy: 'git'
environment: 'production'
deploy-path: 'public_html'
ssh-host: ${{ vars.SSH_HOST }}
ssh-user: ${{ vars.SSH_USER }}
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
git-repo: ${{ vars.GIT_REPO }}

Inputs

Required

InputDescription
strategyDeployment strategy: ftp or git
environmentTarget environment: stage or production
deploy-pathRemote deploy path relative to home (e.g., public_html)
ssh-hostSSH hostname
ssh-userSSH username
ssh-private-keySSH private key content
ssh-known-hostsSSH known hosts entry

Optional (General)

InputDefaultDescription
php-version8.4PHP version for build
node-version22Node.js version for build
package-manageryarnNode package manager (npm or yarn)
remote-php/usr/local/bin/ea-php84Remote PHP binary path
ssh-port65100SSH port
ssh-key-passphrase(empty)SSH key passphrase
releases-keep5Number of releases to keep

FTP Strategy

InputDefaultDescription
ftp-hostFTP hostname
ftp-port21FTP port
ftp-userFTP username
ftp-passwordFTP password

Git Strategy

InputDefaultDescription
git-repoGit repository URL
git-branchmainGit branch to deploy

What the Action Does

  1. Validates inputs — checks strategy-specific required inputs
  2. Sets up SSH — configures agent, key, and known hosts
  3. Creates release directory — timestamped, copies current release as base
  4. Deploys — FTP upload or git clone depending on strategy
  5. Shared resources — symlinks .env and storage/ from shared directory
  6. Post-deploy — runs migrations, clears and rebuilds caches
  7. Activates release — updates current symlink and proxy index.php
  8. Uploads .htaccess — root rewrite to public/
  9. Cleans up — removes old releases beyond keep count

Workflow Dispatch Example

For manual deployments with environment selection:

name: Deploy to Netsons
on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
type: choice
options:
- stage
- production
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- run: composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: yarn install --frozen-lockfile
- run: yarn build
- uses: albertoarena/laravel-netsons-deploy@v1
with:
strategy: 'git'
environment: ${{ github.event.inputs.environment }}
deploy-path: ${{ vars.DEPLOY_PATH }}
ssh-host: ${{ vars.SSH_HOST }}
ssh-user: ${{ vars.SSH_USER }}
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
git-repo: ${{ vars.GIT_REPO }}