# suiteAppPublish

This step uploads suite application assets to our CDN.

## Parameters

| Name      | Description                          | Type     | Default     | Required |
| --------- | ------------------------------------ | -------- | ----------- | -------- |
| appName              | The application name                                        | `String` | n/a         | yes      |
| env                  | The environment ['dev, 'qa', 'prod']                        | `String` | n/a         | yes      |
| awsRegion                  | The aws region name                                         | `String` | 'us-east-1'              | no       |
| awsDeploymentRoleName      | The IAM role name to assume for deployment                  | `String` | 'prod-cdn-deploy-role'   | no       |
| awsDeploymentRoleAccountId | The AWS account ID that owns the deployment role            | `String` | '437795906767'           | no       |
| bucket                     | The S3 bucket name to upload to                             | `String` | '{env}-orcd-cdn'         | no       |
| subpath                    | A subpath to upload and host from                           | `String` | null                     | no       |
| noCacheExtraPatterns       | Extra file patterns to serve with no-store cache headers    | `String` | ''                       | no       |

## Usage

This step requires two parameters, `appName` and `env`.
The `appName` is the name of the suite application. e.g "frontend-settings".
The `env` parameter specifies the hosting domain and the CDN backing storage, S3 bucket.

The files will be hosted from https://[env]-cdn.theorchard.io/[appName] (note that for the "prod" environment we usually skip the "prod-" prefix)

```groovy
suiteAppPublish(
    env: 'qa',
    appName: 'frontend-settings'
)
```

### Customizing the hosting path

Use the `subpath` parameter to specify a subpath under the `appName` folder.
This is used by the [`suiteAppDeployPrInstance`](./suiteAppDeployPrInstance.md) step to upload PR builds to [appName]/prs/[PR id].

```groovy
suiteAppPublish(
    env: 'qa',
    appName: 'frontend-settings',
    subpath: 'prs/123'
)
```

### Adding extra no-cache patterns

By default, `index*.html`, `dml.json`, and `manifest.json` are served with `no-store` cache headers. Use `noCacheExtraPatterns` to add more files to this group. Input is normalized (trimmed, blanks removed).

```groovy
suiteAppPublish(
    env: 'qa',
    appName: 'frontend-workstation',
    noCacheExtraPatterns: 'main.dml.js,main.dml.js.map'
)
```

### Changing the AWS region

Use the `awsRegion` parameter to specify a different region than the default: "us-east-1".

```groovy
suiteAppPublish(
    env: 'qa',
    appName: 'frontend-settings',
    awsRegion: 'us-west-1'
)
```

### Customizing the deployment role

By default, the step assumes the `prod-cdn-deploy-role` IAM role in account `437795906767`. Use `awsDeploymentRoleName` and `awsDeploymentRoleAccountId` to override these when deploying to a different account or using a different role.

```groovy
suiteAppPublish(
    env: 'qa',
    appName: 'frontend-settings',
    awsDeploymentRoleName: 'custom-deploy-role',
    awsDeploymentRoleAccountId: '123456789012'
)
```
