GitHub Action to deploy a website to a Interweb Mozambique VPS over SSH
https://docs.interweb.co.mz
- Python 66.2%
- Shell 33.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github | ||
| action.yml | ||
| CHANGELOG.md | ||
| deploy.sh | ||
| LICENSE | ||
| README.md | ||
| README.pt.md | ||
| repo.json | ||
| vps.py | ||
Deploy on Interweb Mozambique VPS
A GitHub Action that publishes your site on your Interweb Mozambique VPS. It asks the Interweb Mozambique API which server to use and what its IP is, checks that it is running, and copies the files with rsync over SSH.
Before you start
- API key. Create one in the API Center of Meu Interweb with the
vps:readpermission (addvps:writeif you want the action to start a stopped server). Save it in your repository as the secretINTERWEB_API_KEY. - SSH key. Make a key pair just for deploys (
ssh-keygen -t ed25519 -f deploy_key -N ""), adddeploy_key.pubto~/.ssh/authorized_keysof the user on the VPS, and save the private key as the secretVPS_SSH_KEY. - Host key (recommended). Run
ssh-keyscan -p 22 YOUR_VPS_IPand save the output as the secretVPS_KNOWN_HOSTS. Without it, the action trusts the key the server shows at deploy time.
Example
.github/workflows/deploy.yml:
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Build your site here if needed, for example: npm ci && npm run build
- uses: interweb-mz/deploy-on-vps@v1
with:
api-key: ${{ secrets.INTERWEB_API_KEY }}
ssh-private-key: ${{ secrets.VPS_SSH_KEY }}
known-hosts: ${{ secrets.VPS_KNOWN_HOSTS }}
source: ./public
target: /var/www/html
delete: true
exclude: |
.env
uploads/
post-command: systemctl reload nginx
With a single active VPS on the account there is nothing else to say. With several, choose one with server-id (the id of its service) or server-name (its hostname or IP).
Inputs
| Input | Default | What it does |
|---|---|---|
api-key |
API key with vps:read. Empty uses the INTERWEB_API_KEY environment variable. |
|
server-id / server-name |
Which VPS. Empty uses the only active VPS of the account. | |
ssh-private-key |
Private SSH key (required). | |
ssh-user |
root |
SSH user. |
ssh-port |
22 |
SSH port. |
known-hosts |
Host key of the VPS, from ssh-keyscan. |
|
host |
Connect to this address instead of the main IP, such as an additional IP. | |
source |
. |
Folder of the repository to publish. |
target |
Folder on the VPS (required), such as /var/www/html. |
|
delete |
false |
Delete files on the VPS that are not in source. |
exclude |
Paths to leave out, one per line. .git/ and .github/ never go. |
|
rsync-options |
Extra rsync options, such as --chmod=D755,F644. |
|
pre-command / post-command |
Commands run on the VPS, inside target, before and after the copy. |
|
start-if-stopped |
false |
Start the VPS through the API if it is stopped (needs vps:write). |
wait-timeout |
600 |
Seconds to wait for the VPS to be running. |
dry-run |
false |
Show what would be copied, without copying. |
Outputs: server-id, server-name, ip and power-state.
Good to know
- Runs on Linux and macOS runners (they have rsync, ssh and Python 3). Nothing is downloaded.
- A suspended VPS stops the deploy with a clear message. A VPS that is starting or restarting is waited for.
- With a
sandbox_key the API calls are simulated: starting a stopped server does nothing. The copy itself is real, because it goes over SSH. - If your key only accepts some IP addresses, remember that GitHub runners change IP. Use a self-hosted runner or leave the IP list empty for this key.
- The API docs for servers: https://docs.interweb.co.mz/servers/
License
MIT. See LICENSE.
Maintained by RLX Holdings.