This GitHub Action deploys applications to a Plesk server using SCP. If your project is using Node.js, this action will also install dependencies and restart the application.
ssh-private-key
: Required. SSH private key for authentication.ftp-username
: Required. FTP username for the Plesk server.ftp-server
: Required. FTP server address.files-to-copy
: Required. Files or directories to copy to the server.remote-dir
: Optional. Remote directory to copy files to. Defaults to/
.node-version
: Optional. Node.js version to use. Defaults to20
.package-manager
: Optional. Package manager to use (npm
oryarn
). Defaults tonpm
.npm-install
: Optional. Whether to install dependencies. Defaults totrue
.restart
: Optional. Whether to restart the application. Defaults totrue
.clean-remote-dir
: Optional. Whether to clean the remote directory before deployment. Defaults tofalse
.
deployment-status
: Status of the deployment.
v1.1
: Supports choosing which package manager to use (npm
oryarn
).v1
: First release.
Here's an example of how to use the Plesk Deployer Action in a GitHub Actions workflow with npm:
name: Deploy to Plesk
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Deploy to Plesk
uses: celleb/plesk-deployer@v1.1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ftp-username: ${{ vars.FTP_USERNAME }}
ftp-server: ${{ vars.FTP_SERVER }}
files-to-copy: "./dist ./package.json ./package-lock.json"
remote-dir: "./httpdocs"
node-version: 20
npm-install: true
restart: true
clean-remote-dir: true
And here's an example using Yarn:
name: Deploy to Plesk
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build application
run: yarn build
- name: Deploy to Plesk
uses: celleb/plesk-deployer@v1.1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ftp-username: ${{ vars.FTP_USERNAME }}
ftp-server: ${{ vars.FTP_SERVER }}
files-to-copy: "./dist ./package.json ./yarn.lock"
remote-dir: "./httpdocs"
node-version: 20
package-manager: yarn
npm-install: true
restart: true
clean-remote-dir: true
-
Generate an SSH Key:
- Open a terminal and run:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- Follow the prompts to save the key, typically in
~/.ssh/id_rsa
.
- Open a terminal and run:
-
Add the Private Key to GitHub Secrets:
- Copy the contents of your private key file (e.g.,
~/.ssh/id_rsa
). You can use the following command to copy the contents to your clipboard:cat ~/.ssh/id_rsa | pbcopy
- Go to your GitHub repository, navigate to Settings > Secrets and variables > Actions > New repository secret.
- Name the secret
SSH_PRIVATE_KEY
or whatever you want and paste the private key content.
- Copy the contents of your private key file (e.g.,
-
Navigate to Repository Settings:
- Go to your GitHub repository, navigate to Settings > Secrets and variables > Actions > Variables.
-
Add a New Variable:
- Click on New repository variable.
- Enter the variable name (e.g.,
FTP_USERNAME
) and its value. - Repeat for any additional variables needed.
-
Create an FTP User:
- Log in to your Plesk panel.
- Go to Websites & Domains > FTP Access.
- Click Add an FTP Account and fill in the required details.
-
Add Your Public Key to the Server:
- Copy the contents of your public key file (e.g.,
/path/to/your/public/key.pub
). - Use the
ssh-copy-id
command to add your public key to the server:ssh-copy-id -i /path/to/your/public/key.pub username@your_server_hostname
- Replace
/path/to/your/public/key.pub
with the actual path to your public key file. - Replace
username
with your FTP username andyour_server_hostname
with your server's hostname or IP address.
- Copy the contents of your public key file (e.g.,
-
Delete Default Files:
- Ensure that any default
index.html
orindex.php
files are removed from the deployment directory (/httpdocs
or your specifiedremote-dir
). These files can interfere with Node.js applications.
- Ensure that any default
-
Verify Node.js Installation:
- Make sure that Node.js and the specified version are installed and enabled for your domain in Plesk. You can check this in the Plesk panel under Websites & Domains > Node.js.
-
Check Passenger Logs:
- If your application is not starting correctly, check the Passenger logs for errors. These logs can provide insights into what might be going wrong. Logs are typically located in the
/var/log/passenger/passenger.log
directory of your domain or accessible via the Plesk panel. You stream the logs to the console withtail -f /var/log/passenger/passenger.log
- If your application is not starting correctly, check the Passenger logs for errors. These logs can provide insights into what might be going wrong. Logs are typically located in the
Feel free to open issues or submit pull requests for improvements or bug fixes.
This project is licensed under the MIT License.