@tailor-platform/sdk 1.62.0 → 2.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/cli/auth.md CHANGED
@@ -350,7 +350,7 @@ Get an access token for a machine user.
350
350
  **Usage**
351
351
 
352
352
  ```
353
- tailor-sdk machineuser token [options] <name>
353
+ tailor-sdk machineuser token [options] [name]
354
354
  ```
355
355
 
356
356
  <!-- politty:command:machineuser token:usage:end -->
@@ -359,9 +359,9 @@ tailor-sdk machineuser token [options] <name>
359
359
 
360
360
  **Arguments**
361
361
 
362
- | Argument | Description | Required |
363
- | -------- | ----------------- | -------- |
364
- | `name` | Machine user name | Yes |
362
+ | Argument | Description | Required |
363
+ | -------- | --------------------------------------------------------------------------- | -------- |
364
+ | `name` | Machine user name. Falls back to the active profile's default machine user. | No |
365
365
 
366
366
  <!-- politty:command:machineuser token:arguments:end -->
367
367
 
@@ -245,14 +245,14 @@ tailor-sdk function test-run [options] <file>
245
245
 
246
246
  **Options**
247
247
 
248
- | Option | Alias | Description | Required | Default | Env |
249
- | ------------------------------- | ----- | ------------------------------------------------------------------------ | -------- | -------------------- | ----------------------------------- |
250
- | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
251
- | `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
252
- | `--name <NAME>` | `-n` | Workflow job name to run (matches the `name` field of createWorkflowJob) | No | - | - |
253
- | `--arg <ARG>` | `-a` | JSON argument to pass to the function | No | - | - |
254
- | `--machine-user <MACHINE_USER>` | `-m` | Machine user name for authentication | No | - | `TAILOR_PLATFORM_MACHINE_USER_NAME` |
255
- | `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | - |
248
+ | Option | Alias | Description | Required | Default | Env |
249
+ | ------------------------------- | ----- | ---------------------------------------------------------------------------------------------- | -------- | -------------------- | ----------------------------------- |
250
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
251
+ | `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
252
+ | `--name <NAME>` | `-n` | Workflow job name to run (matches the `name` field of createWorkflowJob) | No | - | - |
253
+ | `--arg <ARG>` | `-a` | JSON argument to pass to the function | No | - | - |
254
+ | `--machine-user <MACHINE_USER>` | `-m` | Machine user name for authentication. Falls back to the active profile's default machine user. | No | - | `TAILOR_PLATFORM_MACHINE_USER_NAME` |
255
+ | `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | - |
256
256
 
257
257
  <!-- politty:command:function test-run:options:end -->
258
258
  <!-- politty:command:function test-run:examples:start -->
package/docs/cli/query.md CHANGED
@@ -33,7 +33,7 @@ tailor-sdk query [options]
33
33
  | `--query <QUERY>` | `-q` | Query string to execute directly; omit to start REPL mode | No | - | - |
34
34
  | `--file <FILE>` | `-f` | Read query string from file; omit to start REPL mode | No | - | - |
35
35
  | `--edit` | - | Open a temporary file in your editor; omit to start REPL mode | No | `false` | - |
36
- | `--machine-user <MACHINE_USER>` | `-m` | Machine user name for query execution | Yes | - | `TAILOR_PLATFORM_MACHINE_USER_NAME` |
36
+ | `--machine-user <MACHINE_USER>` | `-m` | Machine user name for query execution. Falls back to the active profile's default machine user. | No | - | `TAILOR_PLATFORM_MACHINE_USER_NAME` |
37
37
  | `--newline-on-enter` | - | REPL: when true, Enter inserts a newline and Shift+Enter submits. Use --no-newline-on-enter to swap. | No | - | - |
38
38
 
39
39
  <!-- politty:command:query:options:end -->
package/docs/cli/setup.md CHANGED
@@ -28,9 +28,9 @@ tailor-sdk setup [command]
28
28
 
29
29
  **Commands**
30
30
 
31
- | Command | Description |
32
- | ------------------------------- | ------------------------------------------------------- |
33
- | [`setup github`](#setup-github) | Generate GitHub Actions workflow for deployment. (beta) |
31
+ | Command | Description |
32
+ | ------------------------------- | ------------------------------------------------- |
33
+ | [`setup github`](#setup-github) | Generate a GitHub Actions deploy workflow. (beta) |
34
34
 
35
35
  <!-- politty:command:setup:subcommands:end -->
36
36
 
@@ -47,7 +47,7 @@ See [Global Options](../cli-reference.md#global-options) for options available t
47
47
 
48
48
  <!-- politty:command:setup github:description:start -->
49
49
 
50
- Generate GitHub Actions workflow for deployment. (beta)
50
+ Generate a GitHub Actions deploy workflow. (beta)
51
51
 
52
52
  <!-- politty:command:setup github:description:end -->
53
53
 
@@ -65,14 +65,16 @@ tailor-sdk setup github [options]
65
65
 
66
66
  **Options**
67
67
 
68
- | Option | Alias | Description | Required | Default |
69
- | --------------------------------------- | ----- | ----------------------------------- | -------- | ------- |
70
- | `--workspace-name <WORKSPACE_NAME>` | `-n` | Workspace name | Yes | - |
71
- | `--workspace-region <WORKSPACE_REGION>` | `-r` | Workspace region | Yes | - |
72
- | `--organization-id <ORGANIZATION_ID>` | `-o` | Organization ID | Yes | - |
73
- | `--folder-id <FOLDER_ID>` | `-f` | Folder ID | Yes | - |
74
- | `--dir <DIR>` | `-d` | App directory (for monorepo setups) | No | `"."` |
75
- | `--with-plan` | `-p` | Include plan job for PR previews | No | `false` |
68
+ | Option | Alias | Description | Required | Default |
69
+ | ----------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
70
+ | `--workspace-name <WORKSPACE_NAME>` | `-n` | Workspace name (defaults to the config 'name') | No | - |
71
+ | `--branch <BRANCH>` | - | Branch target: deploy trigger branch (defaults to the detected default branch). Tag target: tag-reachability guard branch (no guard when omitted) | No | - |
72
+ | `--tag` | - | Generate a tag target (deploy on tag push) | No | `false` |
73
+ | `--tag-pattern <TAG_PATTERN>` | - | Tag glob to match (requires --tag; defaults to v\*) | No | - |
74
+ | `--environment <ENVIRONMENT>` | - | GitHub Environment for the plan/deploy jobs (defaults to the workspace name) | No | - |
75
+ | `--no-plan` | - | Disable the plan job for a branch target (cannot be combined with --tag) | No | `false` |
76
+ | `--dir <DIR>` | `-d` | App directory (for monorepo setups) | No | `"."` |
77
+ | `--force` | - | Discard hand edits / take over unmanaged files and regenerate | No | `false` |
76
78
 
77
79
  <!-- politty:command:setup github:options:end -->
78
80
 
@@ -81,3 +83,7 @@ tailor-sdk setup github [options]
81
83
  See [Global Options](../cli-reference.md#global-options) for options available to all commands.
82
84
 
83
85
  <!-- politty:command:setup github:global-options-link:end -->
86
+
87
+ ## Further reading
88
+
89
+ - [GitHub Actions Integration](../github-actions.md) — usage guide: targets, generated files, secrets, approval gates, and rollback.
@@ -167,16 +167,16 @@ tailor-sdk workflow start [options] <name>
167
167
 
168
168
  **Options**
169
169
 
170
- | Option | Alias | Description | Required | Default | Env |
171
- | ------------------------------- | ----- | -------------------------------------------------------------- | -------- | -------------------- | ----------------------------------- |
172
- | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
173
- | `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
174
- | `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
175
- | `--machine-user <MACHINE_USER>` | `-m` | Machine user name | Yes | - | `TAILOR_PLATFORM_MACHINE_USER_NAME` |
176
- | `--arg <ARG>` | `-a` | Workflow argument (JSON string) | No | - | - |
177
- | `--wait` | `-W` | Wait for execution to complete | No | `false` | - |
178
- | `--interval <INTERVAL>` | `-i` | Polling interval when using --wait (e.g., '3s', '500ms', '1m') | No | `"3s"` | - |
179
- | `--logs` | `-l` | Display job execution logs after completion (requires --wait) | No | `false` | - |
170
+ | Option | Alias | Description | Required | Default | Env |
171
+ | ------------------------------- | ----- | --------------------------------------------------------------------------- | -------- | -------------------- | ----------------------------------- |
172
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
173
+ | `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
174
+ | `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
175
+ | `--machine-user <MACHINE_USER>` | `-m` | Machine user name. Falls back to the active profile's default machine user. | No | - | `TAILOR_PLATFORM_MACHINE_USER_NAME` |
176
+ | `--arg <ARG>` | `-a` | Workflow argument (JSON string) | No | - | - |
177
+ | `--wait` | `-W` | Wait for execution to complete | No | `false` | - |
178
+ | `--interval <INTERVAL>` | `-i` | Polling interval when using --wait (e.g., '3s', '500ms', '1m') | No | `"3s"` | - |
179
+ | `--logs` | `-l` | Display job execution logs after completion (requires --wait) | No | `false` | - |
180
180
 
181
181
  <!-- politty:command:workflow start:options:end -->
182
182
 
@@ -241,11 +241,13 @@ tailor-sdk profile create [options] <name>
241
241
 
242
242
  **Options**
243
243
 
244
- | Option | Alias | Description | Required | Default |
245
- | ------------------------------- | ----- | --------------------------------------------------------------------------------- | -------- | --------- |
246
- | `--user <USER>` | `-u` | User email | Yes | - |
247
- | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | Yes | - |
248
- | `--permission <PERMISSION>` | - | Profile permission. 'read' blocks all write commands while the profile is active. | No | `"write"` |
244
+ | Option | Alias | Description | Required | Default |
245
+ | ------------------------------------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
246
+ | `--user <USER>` | `-u` | User email | Yes | - |
247
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | Yes | - |
248
+ | `--permission <PERMISSION>` | - | Profile permission. 'read' blocks all write commands while the profile is active. | No | `"write"` |
249
+ | `--machine-user <MACHINE_USER>` | `-m` | Default machine user name for application-data commands (query, workflow start, function test-run, machineuser token). | No | - |
250
+ | `--machine-user-override <MACHINE_USER_OVERRIDE>` | - | Whether the command line or TAILOR_PLATFORM_MACHINE_USER_NAME may override the profile's machine user. 'deny' requires --machine-user. | No | - |
249
251
 
250
252
  <!-- politty:command:profile create:options:end -->
251
253
 
@@ -320,11 +322,13 @@ tailor-sdk profile update [options] <name>
320
322
 
321
323
  **Options**
322
324
 
323
- | Option | Alias | Description | Required | Default |
324
- | ------------------------------- | ----- | ------------------------------------------------------------------------------------ | -------- | ------- |
325
- | `--user <USER>` | `-u` | New user email | No | - |
326
- | `--workspace-id <WORKSPACE_ID>` | `-w` | New workspace ID | No | - |
327
- | `--permission <PERMISSION>` | - | Profile permission. 'read' blocks all write commands; 'write' lifts the restriction. | No | - |
325
+ | Option | Alias | Description | Required | Default |
326
+ | ------------------------------------------------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
327
+ | `--user <USER>` | `-u` | New user email | No | - |
328
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | New workspace ID | No | - |
329
+ | `--permission <PERMISSION>` | - | Profile permission. 'read' blocks all write commands; 'write' lifts the restriction. | No | - |
330
+ | `--machine-user <MACHINE_USER>` | `-m` | Default machine user name for application-data commands (query, workflow start, function test-run, machineuser token). Pass an empty string to clear. | No | - |
331
+ | `--machine-user-override <MACHINE_USER_OVERRIDE>` | - | Whether the command line or TAILOR_PLATFORM_MACHINE_USER_NAME may override the profile's machine user. 'deny' requires --machine-user; 'allow' lifts the restriction. | No | - |
328
332
 
329
333
  <!-- politty:command:profile update:options:end -->
330
334
 
@@ -77,7 +77,7 @@ You can use environment variables to configure workspace and authentication:
77
77
  | `TAILOR_PLATFORM_SDK_DTS_PATH` | Output path for generated `tailor.d.ts` type definition file |
78
78
  | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --machine-user` |
79
79
  | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --machine-user` |
80
- | `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run` |
80
+ | `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run`, `machineuser token` |
81
81
  | `TAILOR_BUNDLE_CONCURRENCY` | Max concurrent bundle workers for `deploy` (resolvers/executors/workflows). Defaults to CPU count |
82
82
  | `VISUAL` / `EDITOR` | Preferred editor for commands that open files (e.g., `vim`, `code`, `nano`) |
83
83
  | `TAILOR_CRASH_REPORTS_LOCAL` | Local crash log writing: `on` (default) or `off` |
@@ -287,9 +287,9 @@ Commands for managing crash reports.
287
287
 
288
288
  Commands for setting up project infrastructure.
289
289
 
290
- | Command | Description |
291
- | ------------------------------------------- | ------------------------------------------------------- |
292
- | [setup github](./cli/setup.md#setup-github) | Generate GitHub Actions workflow for deployment. (beta) |
290
+ | Command | Description |
291
+ | ------------------------------------------- | ------------------------------------------------- |
292
+ | [setup github](./cli/setup.md#setup-github) | Generate a GitHub Actions deploy workflow. (beta) |
293
293
 
294
294
  ### [Upgrade Commands](./cli/upgrade.md)
295
295
 
@@ -0,0 +1,337 @@
1
+ # GitHub Actions Integration
2
+
3
+ `tailor-sdk setup github` generates a GitHub Actions workflow that deploys your
4
+ Tailor Platform application automatically on push or tag.
5
+
6
+ > **Beta:** This command is under active development. CLI flags, the generated
7
+ > workflow, and the `.github/tailor-sdk.lock` schema may change before general
8
+ > availability.
9
+
10
+ ## Quick start
11
+
12
+ Run the command from the root of your SDK project (where `tailor.config.ts`
13
+ lives):
14
+
15
+ ```bash
16
+ # Branch target: deploy to stg on every push to main
17
+ tailor-sdk setup github -n my-app-stg
18
+
19
+ # Tag target: deploy to production when a tag is pushed, with an approval gate
20
+ tailor-sdk setup github -n my-app-prod \
21
+ --tag --branch main --environment production
22
+ ```
23
+
24
+ After running the command, follow the **Next steps** printed to the terminal to
25
+ set the required secrets, set the `TAILOR_PLATFORM_WORKSPACE_ID` variable, and
26
+ commit the generated files.
27
+
28
+ The generated workflow deploys to whichever workspace its
29
+ `TAILOR_PLATFORM_WORKSPACE_ID` Environment variable points at — it never
30
+ creates or renames a workspace. Provision the workspace and set that variable
31
+ before the first deploy (see [Targeting a workspace](#targeting-a-workspace)).
32
+
33
+ ## Targets
34
+
35
+ A _target_ is one workflow file that handles one deployment destination.
36
+ Run `setup github` once per target.
37
+
38
+ ### Branch target (recommended for staging)
39
+
40
+ The branch target fires on pull requests and pushes to the branch you specify
41
+ (defaulting to the repository's default branch when `--branch` is omitted):
42
+
43
+ ```bash
44
+ tailor-sdk setup github -n my-app-stg
45
+ # Equivalent to:
46
+ tailor-sdk setup github -n my-app-stg --branch main
47
+ ```
48
+
49
+ What it does:
50
+
51
+ - On **pull request**: runs `generate`, checks that generated files are
52
+ committed (`generate-check`), and posts a deployment plan as a PR comment.
53
+ (The plan and deploy jobs are independent; pull requests run plan only.)
54
+ - On **push to the branch**: deploys. The deploy action runs `generate` and
55
+ applies the config; it does not re-run the PR plan.
56
+ - On **`workflow_dispatch`** with `dry-run: true`: runs plan only (useful for
57
+ rollback verification — see [Rollback](#rollback)). With `dry-run: false`
58
+ (default) it deploys, like a push.
59
+
60
+ Fork pull requests cannot read repository secrets. For forks, the plan step is
61
+ automatically skipped; `generate-check` and other non-secret checks still run.
62
+
63
+ ### Tag target (recommended for production)
64
+
65
+ The tag target fires when a tag matching `--tag-pattern` (default `v*`) is
66
+ pushed:
67
+
68
+ ```bash
69
+ tailor-sdk setup github -n my-app-prod \
70
+ --tag --tag-pattern "v*" --branch main --environment production
71
+ ```
72
+
73
+ What it does:
74
+
75
+ - **`tailor-tag-guard`** (generated when `--branch` is supplied): checks that
76
+ the tagged commit is reachable from `main`. A tag on an unrelated commit is
77
+ silently skipped, not an error.
78
+ - **`tailor-plan`**: runs `generate`, `generate-check`, and posts a plan
79
+ summary to the Actions step summary (no PR comment, because there is no PR).
80
+ - **`tailor-deploy`**: waits for `tailor-plan`, then deploys. If the target
81
+ environment has required reviewers configured, GitHub requires their approval
82
+ before the deploy job starts.
83
+ - On **`workflow_dispatch`**: the `tailor-tag-guard` result is ignored — the
84
+ plan job runs regardless of branch reachability (useful for rolling back to
85
+ any tag). `dry-run: true` stops before the deploy job.
86
+
87
+ ### Choosing `--branch` for the tag target
88
+
89
+ `--branch` has two different roles depending on the target kind:
90
+
91
+ | Target | Role of `--branch` |
92
+ | ------ | ---------------------------------------------------------------------------------------------- |
93
+ | Branch | The branch that triggers the workflow (push + PR base). Defaults to the repo's default branch. |
94
+ | Tag | The branch whose history the tag must be reachable from. Omit to disable the guard entirely. |
95
+
96
+ The workspace name (`--workspace-name`, or the config `name` when omitted) must
97
+ be 3–63 characters of lowercase letters, numbers, and hyphens, and cannot start
98
+ or end with a hyphen. It is used for the generated file name, the workflow
99
+ `name:`, the plan label, and the default GitHub Environment name; it does not
100
+ select which workspace gets deployed (see
101
+ [Targeting a workspace](#targeting-a-workspace)).
102
+
103
+ ## Targeting a workspace
104
+
105
+ The generated `plan` and `deploy` jobs target a workspace by **id**, read from
106
+ the `TAILOR_PLATFORM_WORKSPACE_ID` GitHub Environment variable. They never
107
+ resolve a workspace by name and never create one. Set this variable per
108
+ environment before the first deploy.
109
+
110
+ Because the variable is scoped to a GitHub Environment, both the `plan` and
111
+ `deploy` jobs declare `environment:` so the value resolves. When you omit
112
+ `--environment`, the environment name defaults to the workspace name.
113
+
114
+ 1. Provision the workspace (once per environment) and obtain its id. For now
115
+ this is a manual step:
116
+
117
+ ```bash
118
+ tailor-sdk workspace create # copy the printed workspace id
119
+ ```
120
+
121
+ 2. Set the id as the Environment variable (the environment name is your
122
+ `--environment` value, or the workspace name when omitted):
123
+
124
+ ```bash
125
+ gh variable set TAILOR_PLATFORM_WORKSPACE_ID --env my-app-stg
126
+ ```
127
+
128
+ If `TAILOR_PLATFORM_WORKSPACE_ID` is unset, `deploy` fails because the target
129
+ workspace is not provisioned, and `plan` reports that the workspace is not
130
+ provisioned yet instead of running a dry-run.
131
+
132
+ If the target environment has required reviewers, that approval gate applies to
133
+ the `plan` job as well as `deploy`, because `plan` must enter the environment to
134
+ read the variable. (A token-based read that lets `plan` run without entering the
135
+ environment is planned.)
136
+
137
+ ## Generated files
138
+
139
+ Running `setup github` creates or updates:
140
+
141
+ ### `.github/workflows/tailor-<workspace-name>.yml`
142
+
143
+ The workflow file. The `name:` field is set to `Tailor (<workspace-name>)` so
144
+ you can distinguish multiple workspaces in the Actions UI.
145
+
146
+ Jobs and steps whose `id` starts with `tailor-` are managed by the SDK. Do not
147
+ edit or rename them — the SDK tracks them by id.
148
+
149
+ You can add your own jobs and steps around the managed ones. To add
150
+ project-specific setup (such as private registry authentication or a system
151
+ dependency), add a step _before_ the managed setup steps. For post-install
152
+ extras (such as `playwright install`), add a step _after_ them.
153
+
154
+ Note that re-running `setup github` currently regenerates the whole file: if
155
+ the file differs from what the SDK last wrote — whether you edited a managed
156
+ step or added your own — the command stops and reports the conflict. Pass
157
+ `--force` to discard your edits and regenerate from the current template, then
158
+ re-apply your own steps. (Preserving user-added steps across regeneration is
159
+ planned.)
160
+
161
+ ### `.github/tailor-sdk.lock`
162
+
163
+ A machine-owned JSON file that tracks which files the SDK manages, the inputs
164
+ they were generated from, and their content hashes. **Commit this file. Never
165
+ edit it by hand.** The SDK uses it to recognize its own files on re-runs and to
166
+ detect hand edits.
167
+
168
+ ### `tailor.config.ts` (id injection)
169
+
170
+ If your config does not already have an `id` field, `setup github` injects one.
171
+ This `id` must be committed alongside the workflow file. In CI, `tailor-sdk
172
+ deploy` refuses to inject a new id — if the id were assigned fresh on each CI
173
+ run, every deploy would create a brand-new application and lose ownership of
174
+ previously deployed resources.
175
+
176
+ If your pipeline intentionally deploys a fresh, throwaway application on every
177
+ run (for example an end-to-end test harness that creates and deletes its own
178
+ workspace), set `TAILOR_PLATFORM_SDK_ALLOW_CI_ID_INJECTION=true` to opt back
179
+ into automatic id injection for that pipeline.
180
+
181
+ ## Secrets
182
+
183
+ The generated workflow reads two secrets:
184
+
185
+ | Secret | Description |
186
+ | -------------------------------------------- | -------------------------- |
187
+ | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Machine user client ID |
188
+ | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Machine user client secret |
189
+
190
+ Set them on the target GitHub Environment (the `--environment` value, or the
191
+ workspace name when omitted) with the GitHub CLI:
192
+
193
+ ```bash
194
+ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID --env my-app-stg
195
+ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET --env my-app-stg
196
+ ```
197
+
198
+ Setting them at the environment level isolates each target's credentials and
199
+ keeps them alongside that environment's `TAILOR_PLATFORM_WORKSPACE_ID`
200
+ variable. You can also set them as repository-level secrets if every target
201
+ shares one machine user.
202
+
203
+ ## GitHub Environments (approval gate)
204
+
205
+ Both the `plan` and `deploy` jobs are associated with a GitHub Environment — the
206
+ `--environment` value, or the workspace name when omitted. The environment holds
207
+ that target's `TAILOR_PLATFORM_WORKSPACE_ID` variable and machine-user secrets,
208
+ and lets you:
209
+
210
+ - **Require reviewer approval** before the jobs run (suitable for production).
211
+ - **Scope secrets and the workspace-id variable** to specific environments so
212
+ staging and production deploy to separate workspaces with separate machine
213
+ users.
214
+
215
+ To configure the environment, go to your repository's **Settings → Environments**
216
+ and create an environment whose name matches the target's environment. Add
217
+ required reviewers, the `TAILOR_PLATFORM_WORKSPACE_ID` variable, and the
218
+ environment-scoped secrets there.
219
+
220
+ Required reviewers gate the `plan` job as well, because `plan` must enter the
221
+ environment to read `TAILOR_PLATFORM_WORKSPACE_ID`. (A token-based read that
222
+ lets `plan` run without entering the environment is planned.)
223
+
224
+ ## Manual runs and dry-run
225
+
226
+ You can trigger the workflow manually from **Actions → Run workflow**. The
227
+ `dry-run` input (boolean, default `false`) runs the plan job without
228
+ deploying. Use this to preview what would change before executing a rollback
229
+ or an out-of-band deploy. With `dry-run` off, a branch-target dispatch goes
230
+ straight to deploy (like a push), while a tag-target dispatch runs plan first
231
+ and then deploys.
232
+
233
+ For tag targets, you can select any branch or tag when dispatching manually. The tag-guard check is skipped for manual dispatches, so
234
+ you can deploy any commit regardless of branch membership.
235
+
236
+ ## Monorepo setup
237
+
238
+ For a monorepo where your SDK app lives in a subdirectory, pass `--dir`:
239
+
240
+ ```bash
241
+ tailor-sdk setup github -n my-app --dir apps/backend
242
+ ```
243
+
244
+ The generated workflow adds a `paths` filter on `apps/backend/**` so the
245
+ workflow only runs when that subdirectory changes. The `working-directory` for
246
+ SDK commands is set accordingly.
247
+
248
+ ## Rollback
249
+
250
+ `tailor-sdk deploy` is declarative: redeploying a past configuration returns
251
+ the platform to that state. The recommended rollback approaches are:
252
+
253
+ ### Option 1 — Revert the commit (branch target)
254
+
255
+ ```bash
256
+ git revert <commit-sha>
257
+ git push
258
+ ```
259
+
260
+ The push triggers the deploy job, which applies the reverted configuration. To
261
+ preview the diff first, open the revert as a pull request (the plan job comments
262
+ the diff) or use a `dry-run: true` manual dispatch before merging.
263
+
264
+ ### Option 2 — Advance the tag (tag target)
265
+
266
+ Move the production tag to an earlier commit:
267
+
268
+ ```bash
269
+ git tag -f v1.2.3 <earlier-commit-sha>
270
+ git push --force-with-lease origin v1.2.3
271
+ ```
272
+
273
+ Or create a new tag that points to the earlier commit:
274
+
275
+ ```bash
276
+ git tag v1.2.4 <earlier-commit-sha>
277
+ git push origin v1.2.4
278
+ ```
279
+
280
+ ### Option 3 — Manual dispatch with dry-run verification
281
+
282
+ 1. Go to **Actions → `Tailor (<workspace-name>)` → Run workflow**.
283
+ 2. Enter the tag or ref you want to redeploy.
284
+ 3. Set `dry-run` to `true` and run. Inspect the plan output.
285
+ 4. Run again with `dry-run` set to `false`.
286
+
287
+ For tag targets, the tag-guard step is bypassed on manual dispatch, so you can
288
+ dispatch from any ref. Environment approval (if configured) applies as usual.
289
+
290
+ ### Rollback limitations
291
+
292
+ - **Schema and data are not rolled back.** If the older config expects a schema
293
+ state that no longer exists, the plan may show errors. In that case, review
294
+ the diff carefully before proceeding.
295
+ - **Seed data** is not part of the deployment pipeline and is unaffected by
296
+ rollbacks.
297
+ - **Static websites** are not yet integrated into the generated pipeline.
298
+ Static asset rollbacks must be performed manually.
299
+
300
+ ## Multi-environment example
301
+
302
+ A typical setup with staging and production:
303
+
304
+ ```bash
305
+ # Staging: main → stg (deploy on every push to main)
306
+ tailor-sdk setup github -n my-app-stg
307
+
308
+ # Production: tagged commits → prod, with approval gate and branch guard
309
+ tailor-sdk setup github -n my-app-prod \
310
+ --tag --branch main --environment production
311
+ ```
312
+
313
+ Then provision each workspace and set its id on the matching environment (the
314
+ staging target's environment defaults to `my-app-stg`; production uses
315
+ `production`):
316
+
317
+ ```bash
318
+ gh variable set TAILOR_PLATFORM_WORKSPACE_ID --env my-app-stg
319
+ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID --env my-app-stg
320
+ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET --env my-app-stg
321
+
322
+ gh variable set TAILOR_PLATFORM_WORKSPACE_ID --env production
323
+ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID --env production
324
+ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET --env production
325
+ ```
326
+
327
+ Commit both workflow files and `.github/tailor-sdk.lock`.
328
+
329
+ ## Updating the generated workflow
330
+
331
+ When you upgrade the SDK, re-run `setup github` with the same flags to pick up
332
+ template improvements. If the SDK detects that you have hand-edited a managed
333
+ section, it stops and asks you to use `--force` to overwrite your edits, or to
334
+ move your customizations into your own steps before regenerating.
335
+
336
+ The `.github/tailor-sdk.lock` file records the flags used at generation time,
337
+ so you can check what arguments were used previously.