@postman-cse/onboarding-repo-sync 0.12.0 → 0.13.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Postman, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,164 +1,28 @@
1
1
  # postman-repo-sync-action
2
2
 
3
- Public open-alpha GitHub Action that owns Postman-to-repo sync concerns split out of `api-catalog-demo-infra/.github/actions/finalize`.
3
+ Sync Postman workspace assets into a repository and optionally connect the workspace back to that repository.
4
4
 
5
- ## Scope
5
+ Use this action when a repo should contain the Postman artifacts needed for CI, reviews, and repeatable API test runs:
6
6
 
7
- Retained from finalize:
7
+ - Postman Collection v3 multi-file YAML exports under `postman/collections/`.
8
+ - Postman environment exports under `postman/environments/`.
9
+ - `.postman/resources.yaml` with local-to-cloud resource mappings.
10
+ - Optional `.postman/workflows.yaml` spec-to-collection metadata.
11
+ - Optional generated GitHub Actions workflow for Postman CLI smoke and contract runs.
12
+ - Optional mock server, cloud monitor, workspace repository link, and system environment associations.
8
13
 
9
- - Create or update Postman environments from runtime URLs.
10
- - Associate Postman environments to system environments through Bifrost.
11
- - Create mock servers and smoke monitors from generated collections.
12
- - Export Postman collections in the Collection v3 multi-file YAML directory structure under `postman/collections/` (e.g., `[Baseline] <name>/collection.yaml`, nested folder and request YAML files), and export environments plus `.postman/resources.yaml` into the repository.
13
- - Link the Postman workspace to the repository (GitHub or GitLab) through Bifrost.
14
- - Commit synced artifacts and push them back to the current checked out ref.
15
-
16
- Removed from finalize:
17
-
18
- - Generate Fern docs or write documentation URLs back to GitHub.
19
- - Store AWS deployment orchestration concerns in the public action interface.
20
- - Push directly to `main`.
21
-
22
- For existing repositories, use `generate-ci-workflow: false` to avoid touching workflow files, or set `ci-workflow-path` to materialize the generated pipeline under a non-conflicting filename such as `.github/workflows/postman-sync.yml`.
23
-
24
-
25
- ### Git provider support
26
-
27
- Workspace-to-repository linking via Bifrost supports both **GitHub** and **GitLab** (cloud and self-hosted) repository URLs. When `repo-url` is omitted, the action auto-detects the repository URL from `$GITHUB_REPOSITORY` (GitHub Actions) or `$CI_PROJECT_URL` (GitLab CI). You can also pass an explicit `repo-url` for any git provider.
28
-
29
- ### mTLS / Client Certificate Support
30
-
31
- The generated CI workflow supports client certificates for testing APIs that require mTLS.
32
-
33
- On GitHub, set these repository secrets:
34
-
35
- - `POSTMAN_SSL_CLIENT_CERT_B64`
36
- - `POSTMAN_SSL_CLIENT_KEY_B64`
37
- - `POSTMAN_SSL_CLIENT_PASSPHRASE` (optional)
38
- - `POSTMAN_SSL_EXTRA_CA_CERTS_B64` (optional)
39
-
40
- When you pass the matching inputs to the action with a token that has `secrets:write`, the action can auto-persist these secrets for the generated workflow.
41
-
42
- GitLab CI:
43
-
44
- ```yaml
45
- variables:
46
- POSTMAN_SSL_CLIENT_CERT_B64: $POSTMAN_SSL_CLIENT_CERT_B64
47
- POSTMAN_SSL_CLIENT_KEY_B64: $POSTMAN_SSL_CLIENT_KEY_B64
48
- POSTMAN_SSL_CLIENT_PASSPHRASE: $POSTMAN_SSL_CLIENT_PASSPHRASE
49
- POSTMAN_SSL_EXTRA_CA_CERTS_B64: $POSTMAN_SSL_EXTRA_CA_CERTS_B64
50
- ```
51
-
52
- Bitbucket Pipelines:
53
-
54
- ```yaml
55
- definitions:
56
- variables:
57
- POSTMAN_SSL_CLIENT_CERT_B64: "$POSTMAN_SSL_CLIENT_CERT_B64"
58
- POSTMAN_SSL_CLIENT_KEY_B64: "$POSTMAN_SSL_CLIENT_KEY_B64"
59
- POSTMAN_SSL_CLIENT_PASSPHRASE: "$POSTMAN_SSL_CLIENT_PASSPHRASE"
60
- POSTMAN_SSL_EXTRA_CA_CERTS_B64: "$POSTMAN_SSL_EXTRA_CA_CERTS_B64"
61
- ```
62
-
63
- > **Note:** Bitbucket secured variables have a size ceiling, so large cert chains may need to be split or stored elsewhere.
64
-
65
- Azure DevOps:
66
-
67
- ```yaml
68
- steps:
69
- - script: npx postman-repo-sync-action
70
- env:
71
- POSTMAN_SSL_CLIENT_CERT_B64: $(POSTMAN_SSL_CLIENT_CERT_B64)
72
- POSTMAN_SSL_CLIENT_KEY_B64: $(POSTMAN_SSL_CLIENT_KEY_B64)
73
- POSTMAN_SSL_CLIENT_PASSPHRASE: $(POSTMAN_SSL_CLIENT_PASSPHRASE)
74
- POSTMAN_SSL_EXTRA_CA_CERTS_B64: $(POSTMAN_SSL_EXTRA_CA_CERTS_B64)
75
- ```
76
-
77
- > **Note:** Azure DevOps secret variables must be mapped into step `env`; do not reference them directly on the CLI.
78
-
79
- ### CLI Usage (Non-GitHub CI)
80
-
81
- The `postman-repo-sync` CLI is available for GitLab CI, Bitbucket Pipelines, Azure DevOps, and other CI systems that need the repo sync workflow outside GitHub Actions. GitHub Actions users should continue using the `action.yml` interface.
82
-
83
- Install it globally:
84
-
85
- ```bash
86
- npm install -g postman-repo-sync-action
87
- ```
88
-
89
- Basic usage:
90
-
91
- ```bash
92
- postman-repo-sync \
93
- --project-name core-payments \
94
- --workspace-id ws-123 \
95
- --baseline-collection-id col-baseline \
96
- --smoke-collection-id col-smoke \
97
- --contract-collection-id col-contract \
98
- --postman-api-key "$POSTMAN_API_KEY" \
99
- --result-json ./postman-repo-sync-result.json \
100
- --dotenv-path ./postman-repo-sync.env \
101
- --repo-write-mode commit-only
102
- ```
103
-
104
- The CLI auto-detects the CI provider from environment variables and uses that context to resolve the repository branch, commit SHA, and repo URL. `--repo-write-mode` defaults to `commit-and-push`; use `commit-only` when push credentials are not configured.
105
-
106
- JSON is written to stdout. Use `--result-json` to write the same JSON payload to a file, or `--dotenv-path` to emit shell-sourceable `KEY=VALUE` output with the `POSTMAN_REPO_SYNC_` prefix. All logs go to stderr, so stdout stays reserved for JSON output.
107
-
108
- GitLab CI:
109
-
110
- ```yaml
111
- repo_sync:
112
- image: node:20
113
- script:
114
- - npm install -g postman-repo-sync-action
115
- - postman-repo-sync --project-name core-payments --workspace-id ws-123 --baseline-collection-id col-baseline --smoke-collection-id col-smoke --contract-collection-id col-contract --postman-api-key "$POSTMAN_API_KEY" --result-json postman-repo-sync-result.json --dotenv-path postman-repo-sync.env --repo-write-mode commit-and-push
116
- artifacts:
117
- paths:
118
- - postman-repo-sync-result.json
119
- - postman-repo-sync.env
120
- ```
121
-
122
- Bitbucket Pipelines:
123
-
124
- ```yaml
125
- image: node:20
126
-
127
- pipelines:
128
- default:
129
- - step:
130
- name: Postman repo sync
131
- script:
132
- - npm install -g postman-repo-sync-action
133
- - postman-repo-sync --project-name core-payments --workspace-id ws-123 --baseline-collection-id col-baseline --smoke-collection-id col-smoke --contract-collection-id col-contract --postman-api-key "$POSTMAN_API_KEY" --result-json postman-repo-sync-result.json --dotenv-path postman-repo-sync.env --repo-write-mode commit-and-push
134
- artifacts:
135
- - postman-repo-sync-result.json
136
- - postman-repo-sync.env
137
- ```
138
-
139
- Azure DevOps:
140
-
141
- ```yaml
142
- steps:
143
- - script: |
144
- npm install -g postman-repo-sync-action
145
- postman-repo-sync --project-name core-payments --workspace-id ws-123 --baseline-collection-id col-baseline --smoke-collection-id col-smoke --contract-collection-id col-contract --postman-api-key "$(POSTMAN_API_KEY)" --result-json $(Build.ArtifactStagingDirectory)/postman-repo-sync-result.json --dotenv-path $(Build.ArtifactStagingDirectory)/postman-repo-sync.env --repo-write-mode commit-and-push
146
- displayName: Postman repo sync
147
- ```
148
-
149
- The CLI accepts the same repo-context signals as the action and auto-detects branch, SHA, and repo URL from provider-specific environment variables when available.
150
-
151
- ## Usage
14
+ ## Quick Start
152
15
 
153
16
  ```yaml
154
17
  jobs:
155
18
  repo-sync:
156
19
  runs-on: ubuntu-latest
157
20
  permissions:
158
- actions: write
159
21
  contents: write
22
+ actions: write
160
23
  steps:
161
24
  - uses: actions/checkout@v4
25
+
162
26
  - uses: postman-cs/postman-repo-sync-action@v0
163
27
  with:
164
28
  project-name: core-payments
@@ -167,194 +31,208 @@ jobs:
167
31
  smoke-collection-id: col-smoke
168
32
  contract-collection-id: col-contract
169
33
  environments-json: '["prod","stage"]'
170
- system-env-map-json: '{"prod":"uuid-prod","stage":"uuid-stage"}'
171
34
  env-runtime-urls-json: '{"prod":"https://api.example.com","stage":"https://stage-api.example.com"}'
172
- environment-uids-json: '{}'
173
- repo-write-mode: commit-and-push
174
35
  postman-api-key: ${{ secrets.POSTMAN_API_KEY }}
175
36
  postman-access-token: ${{ secrets.POSTMAN_ACCESS_TOKEN }}
176
37
  github-token: ${{ secrets.GITHUB_TOKEN }}
177
- gh-fallback-token: ${{ secrets.GH_FALLBACK_TOKEN }}
178
-
179
- repo-sync-existing:
180
- runs-on: ubuntu-latest
181
- permissions:
182
- actions: write
183
- contents: write
184
- variables: write
185
- steps:
186
- - uses: actions/checkout@v4
187
- - uses: postman-cs/postman-repo-sync-action@v0
188
- with:
189
- project-name: core-payments
190
- workspace-id: ws-123
191
- baseline-collection-id: col-baseline
192
- smoke-collection-id: col-smoke
193
- contract-collection-id: col-contract
194
- generate-ci-workflow: false
195
- postman-api-key: ${{ secrets.POSTMAN_API_KEY }}
196
38
  ```
197
39
 
198
- ## Current-ref push semantics
40
+ For existing repositories that already own their CI workflow, disable workflow generation:
199
41
 
200
- When `repo-write-mode=commit-and-push`, the action pushes back to the current checked out ref instead of hardcoding `main`. Resolution order is `current-ref`, then `GITHUB_HEAD_REF`, then `GITHUB_REF_NAME`. Pull request merge refs are normalized to `GITHUB_HEAD_REF`. Pushes use `HEAD:refs/heads/<resolved-branch>`.
42
+ ```yaml
43
+ with:
44
+ generate-ci-workflow: false
45
+ ```
201
46
 
202
- If the action writes `.github/workflows/ci.yml`, provide a credential source that can update workflow files. The action prefers `gh-fallback-token` first for workflow-file pushes, then falls back to `github-token`.
47
+ Or write the generated workflow somewhere other than `.github/workflows/ci.yml`:
203
48
 
204
- ### Collection v3 export
49
+ ```yaml
50
+ with:
51
+ ci-workflow-path: .github/workflows/postman-sync.yml
52
+ ```
205
53
 
206
- Collections are exported in the Postman Collection v3 format, producing a multi-file YAML directory structure under `postman/collections/`. Each collection (Baseline, Smoke, Contract) gets its own directory containing `collection.yaml` and nested folder/request YAML files. The `.postman/resources.yaml` manifest maps each v3 collection directory to its Postman UID.
54
+ ## Requirements
207
55
 
208
- The generated CI workflow reads `.postman/resources.yaml` directly to resolve the smoke/contract collection IDs and environment ID for Postman CLI runs. It does not depend on repository variables for those asset mappings.
56
+ - `actions/checkout` must run before this action.
57
+ - `project-name` is required.
58
+ - Provide a valid `postman-api-key`, or provide `postman-access-token` so the action can generate one.
59
+ - `contents: write` is required when `repo-write-mode` commits files.
60
+ - `actions: write` is required when the action writes workflow files.
61
+ - `gh-fallback-token` is recommended when the default `GITHUB_TOKEN` cannot update workflow files or repository secrets.
209
62
 
210
- To match the app scaffold more closely, repo-sync also ensures these directories exist under `postman/`:
63
+ `postman-access-token` is required for workspace-to-repository linking, system environment association, and API key generation. If it is omitted, those integration steps are skipped and the remaining artifact sync can still run with `postman-api-key`.
211
64
 
212
- - `collections`
213
- - `environments`
214
- - `flows`
215
- - `globals`
216
- - `mocks`
217
- - `specs`
65
+ ## What Gets Written
218
66
 
219
- It also writes `postman/globals/workspace.globals.yaml` when missing.
67
+ The default artifact root is `postman/`. The action ensures these directories exist:
220
68
 
221
- Folder and request **names are truncated to 120 characters** per path segment when writing files (with an ellipsis). That avoids `ENAMETOOLONG` when Postman item names are very long (for example, copied from long OpenAPI operation summaries).
69
+ - `postman/collections`
70
+ - `postman/environments`
71
+ - `postman/flows`
72
+ - `postman/globals`
73
+ - `postman/mocks`
74
+ - `postman/specs`
222
75
 
223
- ### Local spec metadata
76
+ Collections are exported as Collection v3 multi-file YAML directories, for example:
224
77
 
225
- Repo-sync now scans the repository for local OpenAPI files and records them in `.postman/resources.yaml` under `localResources.specs`.
78
+ ```text
79
+ postman/collections/[Smoke] core-payments/
80
+ collection.yaml
81
+ <folder>.yaml
82
+ <request>.yaml
83
+ ```
226
84
 
227
- - If `spec-path` is provided, it is used as the preferred local spec for `cloudResources.specs` and `.postman/workflows.yaml`.
228
- - If `spec-path` is omitted and exactly one local OpenAPI file is found, that file is used automatically.
229
- - If the local spec target is ambiguous or missing, repo-sync skips the spec cloud map and `workflows.yaml` rather than emitting incorrect relationships.
85
+ The action also writes `.postman/resources.yaml`. The generated CI workflow reads that file to resolve smoke collection, contract collection, and environment IDs for Postman CLI runs.
230
86
 
231
- When a local spec file and exported collections are both available, repo-sync writes `.postman/workflows.yaml` with `syncSpecToCollection` entries so the spec↔collection relationship metadata matches the app more closely.
87
+ Long Postman folder and request names are truncated to 120 characters per path segment when files are written.
232
88
 
233
- ### Lifecycle and versioning
89
+ When a local OpenAPI spec is found, `.postman/resources.yaml` records it under `localResources.specs`. If `spec-id` and an unambiguous local spec are available, the action also maps the spec under `cloudResources.specs`. When a mapped spec and exported collections are both present, `.postman/workflows.yaml` is written with `syncSpecToCollection` metadata.
234
90
 
235
- `collection-sync-mode` controls collection lifecycle behavior:
91
+ ## Repository Writes
236
92
 
237
- - `refresh` (default): always refresh assets and rewrite `.postman/resources.yaml` for the checked-out ref.
238
- - `reuse`: reuse existing assets from explicit inputs or the checked-out ref's `.postman/resources.yaml`.
239
- - `version`: require a release label (`release-label` input or `github-ref-name`), suffix collection export directories and mock/monitor names with that release label, and reuse only the checked-out ref's `.postman/resources.yaml` mappings.
93
+ `repo-write-mode` controls repository mutation:
240
94
 
241
- `spec-sync-mode` supports `update` (default) and `version`. If either sync mode is `version`, this action requires a derived or explicit release label.
95
+ | Mode | Behavior |
96
+ | --- | --- |
97
+ | `commit-and-push` | Commit generated files and push them back to the current checked out ref. |
98
+ | `commit-only` | Commit generated files without pushing. Use this for customer-managed PR workflows. |
99
+ | `none` | Write files in the workspace only. |
242
100
 
243
- ## Inputs
101
+ For `commit-and-push`, the push target is resolved from `current-ref`, then `GITHUB_HEAD_REF`, then `GITHUB_REF_NAME`. Pull request merge refs are normalized to the PR head branch. Pushes use `HEAD:refs/heads/<resolved-branch>`.
244
102
 
245
- | Input | Default | Notes |
246
- | --- | --- | --- |
247
- | `generate-ci-workflow` | `true` | Set to `false` for existing repos that already own their CI workflow layout. |
248
- | `ci-workflow-path` | `.github/workflows/ci.yml` | Redirect generated CI to a non-conflicting path for existing repos. |
249
- | `project-name` | | Service name used for environments, mock servers, and monitors. |
250
- | `workspace-id` | | Workspace identifier used for workspace-link and export metadata. |
251
- | `baseline-collection-id` | | Baseline collection exported into the repo and used for mock generation. |
252
- | `monitor-type` | `cloud` | Type of monitor to create (`cloud` or `cli`). `cli` uses GitHub Actions cron. |
253
- | `smoke-collection-id` | | Smoke collection used for monitor creation. |
254
- | `contract-collection-id` | | Contract collection exported into the repo. |
255
- | `collection-sync-mode` | `refresh` | Collection lifecycle mode: `refresh`, `reuse`, or `version`. |
256
- | `spec-sync-mode` | `update` | Spec lifecycle mode: `update` or `version`. |
257
- | `release-label` | | Optional release label for versioned naming. Falls back to `github-ref-name` when omitted. |
258
- | `spec-path` | | Optional repo-root-relative path to the local spec file for `resources.yaml` and `workflows.yaml` metadata. |
259
- | `environments-json` | `["prod"]` | Environment slugs to create or update. |
260
- | `repo-url` | | Explicit repository URL (GitHub or GitLab). Defaults to `https://github.com/$GITHUB_REPOSITORY` on GitHub Actions, or `$CI_PROJECT_URL` on GitLab CI. |
261
- | `integration-backend` | `bifrost` | Public open-alpha starts with Bifrost only. |
262
- | `workspace-link-enabled` | `true` | Keeps workspace linking in scope. |
263
- | `environment-sync-enabled` | `true` | Keeps environment association in scope by default for the open-alpha demonstration path. |
264
- | `system-env-map-json` | `{}` | JSON map of environment slug to system environment id. |
265
- | `environment-uids-json` | `{}` | Optional explicit JSON map of environment slug to Postman environment uid. |
266
- | `env-runtime-urls-json` | `{}` | JSON map of environment slug to runtime base URL. |
267
- | `artifact-dir` | `postman` | Root directory for exported Postman artifacts. |
268
- | `repo-write-mode` | `commit-and-push` | Generates files and pushes with current-ref semantics. |
269
- | `current-ref` | | Optional explicit ref override for detached checkouts. |
270
- | `committer-name` | `Postman CSE` | Commit author name for sync commits. |
271
- | `committer-email` | `help@postman.com` | Commit author email for sync commits. |
272
- | `postman-api-key` | | Postman API key for environment, mock, and monitor work. |
273
- | `postman-access-token` | | Postman access token for Bifrost and system environment association. |
274
- | `ssl-client-cert` | | Base64-encoded client certificate for mTLS-enabled API testing. |
275
- | `ssl-client-key` | | Base64-encoded private key paired with `ssl-client-cert`. |
276
- | `ssl-client-passphrase` | | Optional passphrase for the client key. |
277
- | `ssl-extra-ca-certs` | | Base64-encoded extra CA certificates used to trust private certificate chains. |
278
- | `github-token` | | GitHub token for commits, workflow updates, and optional secret persistence. |
279
- | `gh-fallback-token` | | Fallback GitHub token for workflow-file and variable APIs. |
280
- | `ci-workflow-base64` | | Optional base64-encoded workflow content that overrides the built-in CI template. |
103
+ If branch protection requires pull requests, run on a temporary branch with `repo-write-mode: commit-only`, then create the PR in a later workflow step.
281
104
 
282
- ### Contract smoke monitoring
105
+ ## Sync Modes
283
106
 
284
- This repo includes `.github/workflows/contract-smoke.yml`, a scheduled live contract check for the Postman and Bifrost endpoints used by repo-sync.
107
+ `collection-sync-mode` controls collection lifecycle:
285
108
 
286
- Configure these repository secrets before enabling the workflow:
109
+ | Mode | Behavior |
110
+ | --- | --- |
111
+ | `refresh` | Refresh exports and rewrite resource mappings for the current ref. |
112
+ | `reuse` | Reuse explicit IDs or IDs already present in `.postman/resources.yaml`. |
113
+ | `version` | Require a release label and suffix exported collection directories, mock names, and monitor names with that label. |
287
114
 
288
- - `SMOKE_ORG_API_KEY`
289
- - `SMOKE_ORG_ACCESS_TOKEN`
290
- - `SMOKE_NON_ORG_API_KEY`
115
+ `spec-sync-mode` supports:
291
116
 
292
- The smoke workflow verifies `/me`, `/teams`, and Bifrost API key creation so upstream auth or response-shape changes are caught before they break repo-sync runs.
117
+ | Mode | Behavior |
118
+ | --- | --- |
119
+ | `update` | Keep the current spec mapping updated. |
120
+ | `version` | Require a release label and use versioned metadata. |
293
121
 
294
- ### Obtaining `postman-api-key`
122
+ If either mode is `version`, provide `release-label` or run on a ref name that can be used as the release label.
295
123
 
296
- The `postman-api-key` is a Postman API key (PMAK) used for all standard Postman API operations — creating workspaces, uploading specs, generating collections, exporting artifacts, and managing environments.
124
+ ## Monitoring And Mocks
297
125
 
298
- **To generate one:**
126
+ When `baseline-collection-id`, `workspace-id`, and at least one environment are available, the action creates or reuses a mock server.
299
127
 
300
- 1. Open the Postman desktop app or web UI.
301
- 2. Go to **Settings** (gear icon) → **Account Settings** → **API Keys**.
302
- 3. Click **Generate API Key**, give it a label, and copy the key (starts with `PMAK-`).
303
- 4. Set it as a GitHub secret:
304
- ```bash
305
- gh secret set POSTMAN_API_KEY --repo <owner>/<repo>
306
- ```
128
+ When `smoke-collection-id`, `workspace-id`, and at least one environment are available, the action creates or reuses a cloud smoke monitor unless `monitor-type: cli` is set. If `monitor-cron` is empty, a new cloud monitor is created disabled.
307
129
 
308
- > **Note:** The PMAK is a long-lived key tied to your Postman account. It does not require periodic renewal like the `postman-access-token`.
130
+ Use `mock-url` or `monitor-id` to force reuse of existing assets.
309
131
 
310
- ### Obtaining `postman-access-token` (Open Alpha)
132
+ ## mTLS
311
133
 
312
- > **⚠️ Open-alpha limitation:** The `postman-access-token` input requires a manually-extracted session token. There is currently no public API to exchange a Postman API key (PMAK) for an access token programmatically. This manual step will be eliminated before GA.
134
+ The generated CI workflow can run Postman CLI with client certificates. Set these GitHub repository secrets:
313
135
 
314
- The `postman-access-token` is a Postman session token (`x-access-token`) required for internal API operations that the standard PMAK API key cannot perform — specifically workspace ↔ repo git sync (Bifrost) and system environment associations. Without it, those steps are silently skipped.
136
+ - `POSTMAN_SSL_CLIENT_CERT_B64`
137
+ - `POSTMAN_SSL_CLIENT_KEY_B64`
138
+ - `POSTMAN_SSL_CLIENT_PASSPHRASE` (optional)
139
+ - `POSTMAN_SSL_EXTRA_CA_CERTS_B64` (optional)
315
140
 
316
- **To obtain and configure the token:**
141
+ You can also pass the matching action inputs. When `ssl-client-cert` is provided and a GitHub token/repository context is available, the action attempts to persist those values as repository secrets for the generated workflow.
317
142
 
318
- 1. **Log in via the Postman CLI** (requires a browser):
319
- ```bash
320
- postman login
321
- ```
322
- This opens a browser window for Postman's PKCE OAuth flow. Complete the sign-in.
143
+ ## CLI
323
144
 
324
- 2. **Extract the access token** from the CLI credential store:
325
- ```bash
326
- cat ~/.postman/postmanrc | jq -r '.login._profiles[].accessToken'
327
- ```
145
+ The package also ships a `postman-repo-sync` binary for GitLab CI, Bitbucket Pipelines, Azure DevOps, and other CI systems.
328
146
 
329
- 3. **Set it as a GitHub secret** on your repository or organization:
330
- ```bash
331
- # Repository-level secret
332
- gh secret set POSTMAN_ACCESS_TOKEN --repo <owner>/<repo>
147
+ ```bash
148
+ npm install -g @postman-cse/onboarding-repo-sync
149
+
150
+ postman-repo-sync \
151
+ --project-name core-payments \
152
+ --workspace-id ws-123 \
153
+ --baseline-collection-id col-baseline \
154
+ --smoke-collection-id col-smoke \
155
+ --contract-collection-id col-contract \
156
+ --postman-api-key "$POSTMAN_API_KEY" \
157
+ --result-json postman-repo-sync-result.json \
158
+ --dotenv-path postman-repo-sync.env \
159
+ --repo-write-mode commit-only
160
+ ```
333
161
 
334
- # Organization-level secret (recommended for multi-repo use)
335
- gh secret set POSTMAN_ACCESS_TOKEN --org <org> --visibility selected --repos <repo1>,<repo2>
336
- ```
337
- Paste the token value when prompted.
162
+ The CLI auto-detects repository URL, branch, and SHA from common CI environment variables. It writes JSON to stdout, writes the same JSON to `--result-json`, and optionally writes shell-sourceable `POSTMAN_REPO_SYNC_*` values to `--dotenv-path`. Logs go to stderr.
338
163
 
339
- > **Important:** This token is session-scoped and will expire. When it does, operations that depend on it (workspace linking, system environment associations) will silently degrade. You will need to repeat the login and secret update process. There is no automated refresh mechanism.
164
+ ## Inputs
340
165
 
341
- > **Note:** `postman login --with-api-key` stores a PMAK — **not** the session token these APIs require. You must use the interactive browser login.
166
+ | Input | Default | Notes |
167
+ | --- | --- | --- |
168
+ | `project-name` | | Required. Service name used for environments, mock servers, and monitors. |
169
+ | `workspace-id` | | Postman workspace ID. Can be resolved from `.postman/resources.yaml` when available. |
170
+ | `baseline-collection-id` | | Baseline collection exported into the repo and used for mock server creation. |
171
+ | `smoke-collection-id` | | Smoke collection used for monitor creation and generated CI. |
172
+ | `contract-collection-id` | | Contract collection exported into the repo and used for generated CI. |
173
+ | `environments-json` | `["prod"]` | JSON array of environment slugs to create or update. |
174
+ | `env-runtime-urls-json` | `{}` | JSON map of environment slug to runtime base URL. |
175
+ | `environment-uids-json` | `{}` | JSON map of environment slug to existing Postman environment UID. |
176
+ | `system-env-map-json` | `{}` | JSON map of environment slug to system environment ID. |
177
+ | `repo-url` | Auto-detected | Explicit repository URL for workspace linking. Auto-detected from common GitHub, GitLab, Bitbucket, and Azure DevOps CI variables when available. |
178
+ | `artifact-dir` | `postman` | Root directory for exported artifacts. |
179
+ | `repo-write-mode` | `commit-and-push` | `commit-and-push`, `commit-only`, or `none`. |
180
+ | `current-ref` | | Explicit branch/ref override for push target resolution. |
181
+ | `generate-ci-workflow` | `true` | Whether to write the generated CI workflow. |
182
+ | `ci-workflow-path` | `.github/workflows/ci.yml` | Path for the generated CI workflow. |
183
+ | `ci-workflow-base64` | | Base64-encoded workflow content that replaces the built-in template. |
184
+ | `collection-sync-mode` | `refresh` | `refresh`, `reuse`, or `version`. |
185
+ | `spec-sync-mode` | `update` | `update` or `version`. |
186
+ | `release-label` | | Label used for versioned collection/spec sync. |
187
+ | `spec-id` | | Cloud spec UID to persist in `.postman/resources.yaml`. |
188
+ | `spec-path` | | Repo-root-relative local spec path to use for metadata. |
189
+ | `monitor-type` | `cloud` | `cloud` creates/reuses a cloud monitor; `cli` skips cloud monitor creation. |
190
+ | `monitor-id` | | Existing smoke monitor ID to validate and reuse. |
191
+ | `mock-url` | | Existing mock server URL to reuse. |
192
+ | `monitor-cron` | | Cron expression for cloud monitor scheduling. Empty creates a disabled monitor. |
193
+ | `workspace-link-enabled` | `true` | Enable workspace-to-repository linking. Requires `postman-access-token`. |
194
+ | `environment-sync-enabled` | `true` | Enable system environment association. Requires `postman-access-token`. |
195
+ | `integration-backend` | `bifrost` | Backend used for workspace linking and environment association. |
196
+ | `org-mode` | `false` | Include `x-entity-team-id` for org-mode Bifrost calls. |
197
+ | `postman-api-key` | | Postman API key for standard Postman API operations. |
198
+ | `postman-access-token` | | Postman session access token for integration operations and API key generation. |
199
+ | `github-token` | | Token for commits, pushes, workflow updates, and secret persistence. |
200
+ | `gh-fallback-token` | | Preferred fallback token for workflow-file pushes and secret persistence. |
201
+ | `committer-name` | `Postman CSE` | Git committer name for sync commits. |
202
+ | `committer-email` | `help@postman.com` | Git committer email for sync commits. |
203
+ | `ssl-client-cert` | | Base64-encoded PEM client certificate. |
204
+ | `ssl-client-key` | | Base64-encoded PEM private key. Required with `ssl-client-cert`. |
205
+ | `ssl-client-passphrase` | | Optional private-key passphrase. |
206
+ | `ssl-extra-ca-certs` | | Optional base64-encoded PEM CA bundle. |
342
207
 
343
208
  ## Outputs
344
209
 
345
210
  | Output | Meaning |
346
211
  | --- | --- |
347
- | `integration-backend` | Resolved integration backend for the run. |
348
- | `resolved-current-ref` | Resolved push target based on current-ref semantics. |
212
+ | `integration-backend` | Resolved integration backend. |
213
+ | `resolved-current-ref` | Branch used as the push target for `commit-and-push`. |
349
214
  | `workspace-link-status` | `success`, `skipped`, or `failed`. |
350
215
  | `environment-sync-status` | `success`, `skipped`, or `failed`. |
351
- | `environment-uids-json` | JSON map of environment slug to Postman environment uid. |
352
- | `mock-url` | Created mock server URL. |
353
- | `monitor-id` | Created smoke monitor UID. |
354
- | `repo-sync-summary-json` | JSON summary of repo materialization and workspace sync outputs. |
355
- | `commit-sha` | Commit SHA produced by repo-write-mode when a sync commit is created. |
216
+ | `environment-uids-json` | JSON map of environment slug to Postman environment UID. |
217
+ | `mock-url` | Created or reused mock server URL. |
218
+ | `monitor-id` | Created or reused smoke monitor ID. |
219
+ | `repo-sync-summary-json` | JSON summary of commit, environment, mock, monitor, push, and integration state. |
220
+ | `commit-sha` | Commit SHA produced by `repo-write-mode`, when a commit is created. |
356
221
 
357
- ## Local development
222
+ ## Credentials
223
+
224
+ Create a Postman API key in Postman under **Settings -> Account Settings -> API Keys**, then store it as `POSTMAN_API_KEY`.
225
+
226
+ The `postman-access-token` value is a session token used for integration APIs that are not covered by PMAK. To obtain it:
227
+
228
+ ```bash
229
+ postman login
230
+ cat ~/.postman/postmanrc | jq -r '.login._profiles[].accessToken'
231
+ ```
232
+
233
+ Store that value as `POSTMAN_ACCESS_TOKEN`. It expires with the Postman session and must be refreshed when integration steps start skipping or failing because of authentication.
234
+
235
+ ## Local Development
358
236
 
359
237
  ```bash
360
238
  npm install
@@ -363,14 +241,4 @@ npm run typecheck
363
241
  npm run build
364
242
  ```
365
243
 
366
- `npm run build` produces the committed `dist/index.cjs` action bundle used by `action.yml`.
367
-
368
- ## Open-Alpha Release Strategy
369
-
370
- - Open-alpha channel tags use `v0.x.y`.
371
- - Consumers can pin immutable tags such as `v0.2.0` for reproducibility.
372
- - Moving tag `v0` is used only as the rolling open-alpha channel.
373
-
374
- ## REST Migration Seam
375
-
376
- The public input and output contract is backend-neutral. `integration-backend` defaults to `bifrost`, and backend-specific metadata remains internal so a future REST implementation can replace the backend without changing caller workflow syntax.
244
+ `npm run build` produces the committed `dist/index.cjs` action bundle used by `action.yml` and `dist/cli.cjs` for the CLI.
package/action.yml CHANGED
@@ -30,7 +30,7 @@ inputs:
30
30
  description: Contract collection ID used for exported artifacts.
31
31
  required: false
32
32
  collection-sync-mode:
33
- description: Collection sync lifecycle mode (refresh, reuse, or version).
33
+ description: Collection sync lifecycle mode (refresh or version).
34
34
  required: false
35
35
  default: refresh
36
36
  spec-sync-mode:
@@ -47,7 +47,7 @@ inputs:
47
47
  description: Existing mock server URL. When set, the action validates and reuses this mock instead of creating a new one.
48
48
  required: false
49
49
  monitor-cron:
50
- description: Cron expression for monitor scheduling (e.g. '0 */6 * * *'). When empty, the monitor is created in a disabled state.
50
+ description: Cron expression for monitor scheduling (e.g. '0 */6 * * *'). When empty, the monitor is created disabled and triggered to run once per workflow invocation (and once on every subsequent run).
51
51
  required: false
52
52
  default: ""
53
53
  environments-json:
@@ -137,6 +137,10 @@ inputs:
137
137
  spec-path:
138
138
  description: Optional repo-root-relative path to the local spec file for resources/workflows metadata.
139
139
  required: false
140
+ postman-stack:
141
+ description: Postman stack profile.
142
+ required: false
143
+ default: prod
140
144
  outputs:
141
145
  integration-backend:
142
146
  description: Resolved integration backend for the open-alpha run.
@@ -157,5 +161,5 @@ outputs:
157
161
  commit-sha:
158
162
  description: Commit SHA produced by repo-write-mode, if any.
159
163
  runs:
160
- using: node20
164
+ using: node24
161
165
  main: dist/index.cjs