Composite Forgejo/GitHub Action that deploys files to a remote server over SSH using rsync. Supports configurable host, port, username, key, source directory, target path, and extra rsync args.
1.5 KiB
1.5 KiB
SSH Deploy Action
A Forgejo/GitHub Action to deploy files to a remote server via SSH and rsync.
Inputs
| Input | Description | Required | Default |
|---|---|---|---|
host |
SSH server address | Yes | |
port |
SSH port | No | 22 |
username |
SSH login user | Yes | |
key |
Private SSH key content | Yes | |
source |
Local directory to deploy | No | . |
target |
Remote path on the server | Yes | |
args |
Extra rsync flags (e.g. --delete) |
No |
Usage
steps:
- uses: actions/checkout@v4
- name: Build
run: npm run build
- name: Deploy
uses: fmartingr/ssh-deploy-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: dist/
target: ${{ secrets.SSH_PATH }}
With extra rsync flags
- name: Deploy
uses: fmartingr/ssh-deploy-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: dist/
target: ${{ secrets.SSH_PATH }}
args: --delete --exclude='.env'
SSH Key Setup
-
Generate a dedicated deploy key:
ssh-keygen -t ed25519 -C "deploy" -f deploy_key -N "" -
Add the public key to the server:
cat deploy_key.pub >> ~/.ssh/authorized_keys -
Add the private key content as a secret (e.g.
SSH_PRIVATE_KEY) in your Forgejo/GitHub repository settings.
License
MIT