Deployment Target Overview

Site files are published to Deployment Targets.

Each site can have multiple deployment targets, and users can be granted access to different deployment targets based on their role.

Deployment Target can be added and modified in the Deployment Target administration:

  1. In the jsHarmony CMS, click on the "Sites" tab
  2. Click the edit button on the target site to open the Site Config
  3. The Overview tab lists the deployment targets.  Add a Deployment Target, or click Edit on an existing Deployment Target to update.

Most deployment target settings can be managed through the user interface:


Advanced options can be configured through the JSON tab.

In the JSON config, Deployment Target settings consist of the Publish Path and the Publish Config, detailed below.

Publish Path

The Publish Path defines where the files will be published.  Supported Deployment Target types are listed below, together with relevant notes:

SFTP
sftp://username:password@host:port/path
* Download a Public Key for authentication from the Deployment Target settings page
* Be sure to review the "ftp_config.delete_excess_files" Publish Config option

FTPS
ftps://username:password@ftp.domain.com:port/path
* Be sure to review the "ftp_config.delete_excess_files" Publish Config option

FTP
ftp://username:password@ftp.domain.com:port/path
* Be sure to review the "ftp_config.delete_excess_files" Publish Config option

Local Filesystem
file://c:/path/to/folder/
* Be sure to review the "fs_config.delete_excess_files" Publish Config option

CMS Deployment Host
cmshost://hostid
* Send files to a remote host that is running the jsharmony-cms-host program

Amazon S3
s3://path/to/bucket/
* Set access key and secret key in "s3_config" Publish Config settings

Git HTTPS
git_https://username:password@host/path
* Set the git branch in the "git_config.branch" parameter

Git SSH
git_ssh://username@host/path
* Download a Public Key for authentication from the Deployment Target settings page
* Set the git branch in the "git_config.branch" parameter

Publish Config

The Publish Config is defined as JSON, with the following properties:

{
  //FTP/FTPS/SFTP publish settings
  "ftp_config": {
    "overwrite_all": false,         //For FTP / FTPS / SFTP, if true, always upload all files, instead of comparing size and MD5
    "delete_excess_files": false,   //For FTP / FTPS / SFTP, if true, delete excess files in destination that weren't in the publish build

    "ignore_certificate_errors": false,    //For FTPS, ignore self-signed certificate errors
    "compression": false,                  //For FTP / FTPS, whether to enable compression
  },

  //Local Filesystem deployment settings
  "fs_config": {
    "delete_excess_files": false,   //If true, delete excess files in destination that weren't in the publish build
  },

  //CMS Deployment Host settings
  "cmshost_config": {
    "download_remote_templates": false,   //Download remote templates via Deployment Host
    "remote_timeout": 60,                 //Timeout (seconds) for downloading remote templates
  },

  //Amazon S3 deployment settings
  "s3_config": {
    "accessKeyId": "",
    "secretAccessKey": "",
    "upload_params": { //Add parameters to the S3.upload request
      //"ACL": "public-read",
      //More parameters can be found at:
      //https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property
    }
  },


  //Git deployment settings
  "git_config": {
    "branch": "master", //Branch where the files will be uploaded
    "options": {        //Any additional git config options can be used
      "user.email": "cms@localhost",
      "user.name": "CMS"
    }
  },

  //Advanced options
  "page_subfolder": "",            //Store CMS page files in a subfolder of the publish directory, ex. 'pages/'
  "media_subfolder": "",           //Store CMS media files in a subfolder of the publish directory, ex. 'media/'
  "url_prefix": "/",               //Prefix for URLs on publish, ex. '/content/'.  Can be used in page templates as %%%url_prefix%%%
  "url_prefix_page_override": null,  //Override URL prefix for CMS page URLs, ex. '/pages/'
  "url_prefix_media_override": null, //Override URL prefix for CMS media URLs, ex. '/media/'
  "published_url": null,  //(Optional) URL of published site, ex. https://example.com
  "exec_pre_deployment": null,     //Execute shell command after populating publish folder, before deployment
                                   //Ex. { cmd: 'cmd', params: ['/c', 'echo abc > c:\\example.txt'] }
  "exec_post_deployment": null,    //Execute shell command after deployment
                                   //Ex. { cmd: 'cmd', params: ['/c', 'echo abc > c:\\example.txt'] }
  "git_branch": "site_%%%SITE_ID%%%",    //Git branch used for deployment.  The %%%SITE_ID%%% parameter is replaced with the site id.
  "copy_folders": ["dir1","dir2"], //Copy contents from these source folders into the publish folder
  "publish_local_templates": false, //Whether to include the site's "templates" folder in the published files
  "ignore_remote_template_certificate": false, //When downloading remote templates, ignore self-signed certificate errors
  "generate": { //Select which branch items will be generated on publish
    "onBeforeDeploy": true,      //true (all), false (none), or array of items, ex: ["page","media"]
    "onDeploy": true,            //true (all), false (none), or array of items, ex: ["page","media"] 
    "onDeploy_PostBuild": true,  //true (all), false (none), or array of items, ex: ["page","media"]
  },
}

Template Variables

The Deployment Target Template Variables are a JSON array of variables that can be used in:

  • Page Templates (source code)
  • Component Templates (source code)
  • Remote Template URLs. 


Using Template Variables

For example, if the Template Variables are defined as:

{
  "env": "prod",
  "base_url": "https://www.example.com"
}

The Page Templates and Component Templates can use those variables in the HTML by wrapping them in "%%%", for example:

<a href="%%%base_url%%%/example.html"></a>

The Remote Template URLs also can use those variables by wrapping them in "%%%":

%%%base_url%%%/template.html?config=%%%env%%%


Defining Template Variables

Template Variables can be defined under the Deployment Target settings, on the "Template Variables" tab.

Additionally, default values for template variables can be defined in the Site Config JSON, using the "template_variables" property.

Template Variables can be defined a variety of ways, including support for different values for the Editor and for Publishing:

{
  "key": "value",   //Same value for both Editor and Publish

  "key": {          //Different values for Editor and Publish
    "editor": "value_1",
    "publish": "value_2"
  },

  "key": {          //Value only for Editor
    "editor": "value_3"
  },

  "key": {          //Value only for Publish
    "publish": "value_4"
  },
}


Built-In Template Variables

The following built-in variables are always available:

{
  "url_prefix": "/",            //The URL Prefix as defined in the Deployment Target Config
  "timestamp": "1630809011735", //The current timestamp, in milliseconds since Epoch
}
Loading
Loading