Updating game server files manually via FTP is time-consuming and prone to human error. By leveraging GitHub Actions, you can implement a professional CI/CD (Continuous Integration/Continuous Deployment) pipeline that automatically syncs your repository changes to your Pterodactyl server every time you push code. This guide ensures your plugins, mods, and configurations stay updated with zero manual effort.
Why Automate Your Server Deployment?
- Efficiency: No more manual dragging-and-dropping files.
- Consistency: Ensures the server always matches your
mainbranch. - Security: Keeps your SFTP credentials encrypted within GitHub’s infrastructure.
- Version Control: Easily roll back to a previous server state by reverting a commit.
Prerequisites
Before you begin, ensure you have gathered your SFTP Details from the GGServers panel. You can find these under Settings → SFTP Details on your server dashboard. You will need:
- Connection Address (Host)
- SFTP Port (Usually 2022)
- Username
- Password (Your panel login password)
Step 1: Configure GitHub Repository Secrets
Hardcoding passwords into your workflow files is a major security risk. Instead, use GitHub Secrets to encrypt your credentials.
- Navigate to your GitHub repository.
- Click Settings → Secrets and variables → Actions.
- Click New repository secret for each of the following:
| Secret Name | Description / Value |
|---|---|
SFTP_HOST |
Your server’s Connection Address/IP. |
SFTP_PORT |
Usually 2022. |
SFTP_USERNAME |
Your unique Pterodactyl SFTP username. |
SFTP_PASSWORD |
Your GGServers panel password. |
Step 2: Create the Deployment Workflow
GitHub Actions uses .yml files to define automation. Create a new file in your repository at the following path: .github/workflows/main.yml and paste the code below:
name: Deploy to GGServers
on:
push:
branches:
- main # Triggers deployment when you push to the main branch
jobs:
deploy:
name: SFTP Sync
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Sync Files via LFTP
uses: pressidium/lftp-mirror-action@v1
with:
host: ${{ secrets.SFTP_HOST }}
port: ${{ secrets.SFTP_PORT }}
user: ${{ secrets.SFTP_USERNAME }}
pass: ${{ secrets.SFTP_PASSWORD }}
localDir: "./" # Root of your GitHub repo
remoteDir: "/" # Root of your server files
options: "--delete --verbose --exclude .git/ --exclude .github/"
Key Parameters Explained:
- –delete: This removes files on the server that are no longer in your GitHub repo. Warning: Use carefully if you have server-generated logs or save files.
- localDir/remoteDir: Adjust these if you only want to sync specific folders, such as
/plugins. - exclude: Prevents Git-related files from being uploaded to your game server.
Step 3: Advanced Optimization (Optional)
Automatic Server Restart
To apply changes (like plugin updates), you often need to restart the server. You can add a curl step to the end of your workflow to trigger the Pterodactyl API. Ensure you have generated a Client API Key in the panel settings first.
- name: Restart Server
run: |
curl -X POST "https://panel.ggservers.com/api/client/servers/YOUR_SERVER_ID/power" \
-H "Authorization: Bearer ${{ secrets.PTERO_API_KEY }}" \
-H "Content-Type: application/json" \
-H "Accept: Application/vnd.pterodactyl.v1+json" \
-d '{"signal": "restart"}'
Common Troubleshooting
- Connection Refused: Double-check that your
SFTP_PORTis set to 2022 and yourSFTP_HOSTis correct. - Permission Denied: Ensure your SFTP username matches the one found in the “Settings” tab of the panel.
- Workflow Not Triggering: Ensure your file is located exactly at
.github/workflows/main.yml.
Take your server management to the next level with GGServers. Our Pterodactyl-powered panels are fully compatible with modern CI/CD workflows, providing the speed and reliability professional server owners demand.
🔥 Ready for a performance upgrade? Use code KB30 for 30% off your next game server at GGServers.com.