Skip to main content

Deployment

This guide explains how to deploy a self-hosted instance of LiveCodes using the included GitHub Actions workflows, and the npm run deploy script.

LiveCodes is a client-side app, so the built static app can be deployed to almost any static file server or CDN (see the Self-Hosting guide). However, if you need the server-side services (short-URL sharing, broadcast server, etc), you can use the Docker setup (for a VPS) or the PHP setup (for shared hosting). Both include GitHub Actions workflows for continuous deployment.

Deploy Actions

The following deployment actions are available in the forked repository:

ActionTargetRequirements
Deploy to GitHub PagesStatic app on GitHub PagesNo secrets required
Deploy to FTPStatic app on an FTP serverFTP secrets
Deploy via SSHStatic app on a serverSSH secrets
Deploy to DockerDocker setup on a VPSVariable VPS_ENV + SSH secrets
Deploy to PHPPHP setup on shared hostingVariable PHP_ENV + MySQL secrets + FTP and/or SSH secrets

All actions run automatically on push to the main branch, and can also be triggered manually from the Actions tab, optionally specifying the branch to deploy (defaults to main).

npm Script

npm run deploy

Builds the app and publishes it to GitHub Pages:

npm run deploy

This is used by the Deploy to GitHub Pages action, and can also be run locally.

Repository Settings

Actions are enabled/disabled using repository variables (non-sensitive configuration) and secrets (sensitive values). Both are configured in the forked repo settings: Settings → Secrets and variables → Actions.

The following variables are used:

VariableUsed byPurpose
VPS_ENVDeploy to Docker.env-format key=value pairs for the Docker environment variables. Required — the action only runs when it is set
PHP_ENVDeploy to PHP.env-format key=value pairs for non-sensitive PHP configuration. Required — the action only runs when it is set. When set, the standalone Deploy to FTP and Deploy via SSH actions are skipped

So for a plain static deploy, leave PHP_ENV unset.

Deploy to GitHub Pages

Deploys the static app to GitHub Pages.

Required secrets/variables: None.

Optional secrets (to authenticate the deploy with a GitHub App instead of the default token):

SecretDescription
CI_APP_ID(optional) GitHub App ID
CI_APP_PRIVATE_KEY(optional) GitHub App private key

When both are set, the deploy is authenticated with the GitHub App; otherwise the default token is used.

Deploy via FTP

Deploys the static app to an FTP server.

Required secrets:

SecretDescription
FTP_HOSTFTP server hostname
FTP_USERFTP user
FTP_PASSWORDFTP password

Optional secrets:

SecretDescription
FTP_PORTFTP port
FTP_PROTOCOLFTP protocol (ftp, ftps or ftps-legacy)
FTP_PATHRemote path of the document root (e.g. /public_html/)
note

The action only runs when FTP_HOST is set. It does not run when the repository variable PHP_ENV is set (use the Deploy to PHP action instead, which can also deploy via FTP).

Deploy via SSH

Deploys the static app to a server over SSH.

Required secrets:

SecretDescription
SSH_HOSTSSH server hostname
SSH_USERSSH user
SSH_KEYSSH private key

Optional secrets:

SecretDescription
SSH_PORTSSH port
SSH_PATHRemote path of the document root
note

The action only runs when SSH_HOST is set. It does not run when the repository variable PHP_ENV is set (use the Deploy to PHP action instead, which can also deploy via SSH).

Deploy to Docker

Deploys the Docker setup to a VPS over SSH: updates the app on the server, applies the VPS_ENV configuration, and restarts the Docker containers.

This assumes you have followed the Docker Getting Started instructions and cloned the repo to your VPS.

Required variable:

VariableDescription
VPS_ENV.env-format key=value pairs for the Docker environment variables (e.g. HOST_NAME, PORT, SELF_HOSTED_SHARE, SELF_HOSTED_BROADCAST, BROADCAST_TOKENS, SANDBOX_HOST_NAME, FIREBASE_CONFIG, LOG_URL). The action only runs when it is set

Required secrets:

SecretDescription
VPS_HOSTSSH hostname of the VPS
VPS_USERSSH user
VPS_KEYSSH private key

Optional secret:

SecretDescription
VPS_PASSPHRASEPassphrase of the SSH private key, if any

Deploy to PHP

Deploys the PHP setup to shared hosting: builds the app, prepares the PHP server files and configuration, and uploads everything to your hosting over FTP and/or SSH (each runs only when the corresponding credentials are configured).

This assumes you have followed the PHP Getting Started instructions (MySQL database and a sandbox subdomain).

Required variable:

VariableDescription
PHP_ENVNon-sensitive config as .env-format key=value pairs, one per line. The action only runs when it is set

PHP_ENV supported keys (same as the Docker environment variables):

KeyDescription
HOST_NAMEHostname of the app (e.g. example.com)
SANDBOX_HOST_NAMEHostname of the sandbox (e.g. sandbox.example.com)
SELF_HOSTED_SHAREEnable share service (true/false)
SELF_HOSTED_BROADCASTEnable broadcast server (true/false)
FIREBASE_CONFIG(optional) Firebase config object (JSON), used for authentication
LOG_URL(optional) Full URL to send server-side analytics (e.g. https://api.website.com/log)

Example:

HOST_NAME=example.com
SANDBOX_HOST_NAME=sandbox.example.com
SELF_HOSTED_SHARE=true
SELF_HOSTED_BROADCAST=true
FIREBASE_CONFIG={"apiKey":"..."}
LOG_URL=https://api.example.com/log

Required secrets:

SecretDescription
MYSQL_HOSTMySQL hostname (usually localhost)
MYSQL_USERMySQL user
MYSQL_PASSWORDMySQL password
MYSQL_DATABASEMySQL database name

Optional secrets:

SecretDescription
MYSQL_PORTMySQL port (default 3306)
BROADCAST_TOKENS(optional) Comma-separated list of broadcast user tokens
API_TOKEN(optional) Token sent with the analytics requests

Deploy via FTP (runs when FTP_HOST is set):

SecretDescription
FTP_HOSTFTP server hostname
FTP_USERFTP user
FTP_PASSWORDFTP password
FTP_PORTFTP port
FTP_PROTOCOLFTP protocol (ftp, ftps or ftps-legacy)
FTP_PATHRemote path of the document root (e.g. /public_html/)

Deploy via SSH (runs when SSH_HOST is set):

SecretDescription
SSH_HOSTSSH server hostname
SSH_USERSSH user
SSH_KEYSSH private key
SSH_PORTSSH port
SSH_PATHRemote path of the document root