This API provides endpoints for managing game deployments and releases:
/preDeploy/:game/:env/:version- Prepares new build directory for deployment./postDeploy/:game/:env/:version- Finalizes deployment, creates symlinks, and manages build info./deployments/:game/:env- Lists all deployments for a specific game environment./deployments/:game/:env/:version- Gets info about a specific deployment.
/publish/:game/:platform/:buildKey?- Publishes a new build as a release./rollback/:game/:platform/:buildKey?- Rolls back to a previous release./releases/:game/:platform- Lists all releases for a game/platform./releases/:game/:platform/current- Gets info about the current release./releases/:game/:platform/:buildKey- Gets info about a specific release.
- Bearer token authentication can be enabled/disabled via environment variables.
- When enabled, all requests must include a valid bearer token.
- Stores each game build in its own directory with build info and assets.
- Manages releases through
releases.jsonfile and symlinks. - Maintains deployment history and release states.
The deployment workflow consists of three main phases:
-
Prepare for deployment
GET /preDeploy/:game/:env/:version
- Creates a new directory for your build
- Returns the
newBuildDirpath for game files - Example:
/preDeploy/my-game/staging/42
-
Upload game files
- Copy game build files (index.html, assets, etc.) to the
newBuildDir - Include
build_info.jsonwith version, git info, and build timestamp
- Copy game build files (index.html, assets, etc.) to the
-
Finalize deployment
GET /postDeploy/:game/:env/:version
- Validates the deployment
- Creates
latestsymlink - Manages old deployments cleanup
- Example:
/postDeploy/my-game/staging/42
-
Publish the build
GET /publish/:game/:platform/:buildKey
- Publishes a deployed build as a release
- Creates necessary symlinks and release info
- Example:
/publish/my-game/facebook/staging-42
-
Verify the release
GET /releases/:game/:platform/current
- Confirms the current active release
- Example:
/releases/my-game/facebook/current
-
Check available releases
GET /releases/:game/:platform
- Lists all available releases with their info
- Shows release history for rollback selection
- Example:
/releases/my-game/facebook
-
Perform rollback
GET /rollback/:game/:platform/:buildKey
- Reverts to a specific previous release
- Updates the current release pointer
- Updates necessary symlinks
- Example:
/rollback/my-game/facebook/staging-41
Note: Omitting buildKey automatically rolls back to the previous release.
-
Verify rollback
GET /releases/:game/:platform/current
- Confirms the active release after rollback
- Example:
/releases/my-game/facebook/current
- List all deployments:
GET /deployments/:game/:env - Check deployment details:
GET /deployments/:game/:env/:version - View release history:
GET /releases/:game/:platform
- Each deployment requires
build_info.jsonandindex.htmlfiles - The system maintains complete deployment and release history
- Rollback operations are reversible
- Authentication requires a Bearer token when enabled
This section describes how to deploy the API service itself.
Deployment is done with PM2.
You will need to install Bun and PM2 on the host machine. Refer to package.json for the Bun version used in the project.
Also, you will need to add SSH keys to host machine so it will be able to clone git repo with the project.
After that, you must run the following command to prepare the deployment:
pm2 deploy ecosystem.config.js production setupThen you can deploy the app with the following command:
pm2 deploy ecosystem.config.js productionYou will need to set up a reverse proxy with your server software to forward requests to the port where the app is running.
I use Caddy as a web server, here is the section of my Caddyfile (by default it is located at /etc/caddy/Caddyfile):
your-domain.com {
# Set this path to your site's directory.
root * /var/www/html
# ...more settings...
# path relative to the root
handle_path /papa-cherry-2/releases* {
# notice that we have to specify the port here, use the same port as in the Bun server config
reverse_proxy localhost:4000
}
}
Use bun run test instead of bun test. Because bun test uses the Bun test runner but we use vitest for the current project.