@postman-cse/onboarding-bootstrap 0.9.1

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.
@@ -0,0 +1,2 @@
1
+ self-hosted-runner:
2
+ labels: []
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+ - cs-beta-actions_20260305
9
+
10
+ jobs:
11
+ validate:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '20'
18
+ cache: npm
19
+ - run: npm ci
20
+ - run: npm test
21
+ - run: npm run typecheck
22
+ - run: npm run check:dist
23
+
24
+ actionlint:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: actions/setup-go@v5
29
+ with:
30
+ go-version: '1.23'
31
+ - name: Install actionlint
32
+ run: go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.11
33
+ - name: Run actionlint
34
+ run: |
35
+ ACTIONLINT_BIN="$(go env GOPATH)/bin/actionlint"
36
+ "$ACTIONLINT_BIN"
@@ -0,0 +1,62 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ release:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '20'
21
+ cache: npm
22
+ - uses: actions/setup-go@v5
23
+ with:
24
+ go-version: '1.23'
25
+ - run: npm ci
26
+ - run: npm test
27
+ - run: npm run typecheck
28
+ - run: npm run check:dist
29
+ - name: Install actionlint
30
+ run: go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.11
31
+ - name: Run actionlint
32
+ run: |
33
+ ACTIONLINT_BIN="$(go env GOPATH)/bin/actionlint"
34
+ "$ACTIONLINT_BIN"
35
+ - name: Publish GitHub release
36
+ uses: softprops/action-gh-release@v2
37
+ with:
38
+ generate_release_notes: true
39
+ - name: Verify version matches tag
40
+ run: |
41
+ TAG="${GITHUB_REF#refs/tags/v}"
42
+ PKG_VERSION=$(node -p "require('./package.json').version")
43
+ if [ "$TAG" != "$PKG_VERSION" ]; then
44
+ echo "::error::Tag v$TAG does not match package.json version $PKG_VERSION"
45
+ exit 1
46
+ fi
47
+ - uses: actions/setup-node@v4
48
+ with:
49
+ node-version: '20'
50
+ registry-url: 'https://registry.npmjs.org'
51
+ - name: Publish to npm
52
+ run: npm publish --provenance --access public
53
+ env:
54
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55
+ - name: Attach npm tarball to release
56
+ run: |
57
+ npm pack
58
+ mv ./*.tgz release.tgz
59
+ - name: Upload tarball
60
+ uses: softprops/action-gh-release@v2
61
+ with:
62
+ files: release.tgz
package/README.md ADDED
@@ -0,0 +1,261 @@
1
+ # postman-bootstrap-action
2
+
3
+ Public open-alpha GitHub Action for Postman workspace bootstrap from a registry-backed OpenAPI spec.
4
+
5
+ ## Scope
6
+
7
+ This action preserves the bootstrap slice of the API Catalog demo flow:
8
+
9
+ - create or reuse a Postman workspace
10
+ - assign the workspace to a governance group through the current Bifrost and internal path
11
+ - invite the requester and add workspace admins
12
+ - upload or update a remote spec in Spec Hub (after normalizing operation summaries — see below)
13
+ - lint the uploaded spec by UID with the Postman CLI
14
+ - generate missing baseline, smoke, and contract collections or reuse existing ones
15
+ - inject generated tests and apply collection tags
16
+ - persist bootstrap repo variables needed by downstream sync work
17
+
18
+ The public open-alpha contract uses kebab-case inputs and outputs and defaults `integration-backend` to `bifrost`.
19
+
20
+ ### Git provider support
21
+
22
+ Workspace-to-repository linking via Bifrost supports both **GitHub** and **GitLab** (cloud and self-hosted) repository URLs. The `repo-url` value (or the auto-derived URL from CI environment variables) is stored as-is by Bifrost without provider-specific validation. URL normalization handles HTTPS, SSH (`git@`), and `.git` suffix variants for both providers.
23
+ The public open-alpha contract uses kebab-case inputs and outputs and defaults `integration-backend` to `bifrost`.
24
+
25
+ For existing services, pass `workspace-id`, `spec-id`, and any existing collection IDs to rerun the bootstrap safely without creating duplicate Postman assets. When GitHub repo variable persistence is enabled, the action also falls back to `POSTMAN_WORKSPACE_ID`, `POSTMAN_SPEC_UID`, `POSTMAN_BASELINE_COLLECTION_UID`, `POSTMAN_SMOKE_COLLECTION_UID`, and `POSTMAN_CONTRACT_COLLECTION_UID` on reruns.
26
+
27
+ ### Team ID derivation
28
+
29
+ The action automatically derives the Postman Team ID from your `postman-api-key` via the `/me` API. There is no need to supply a separate team ID input. If the environment variable `POSTMAN_TEAM_ID` is set, that value takes precedence.
30
+
31
+ ### OpenAPI operation summaries (normalization)
32
+
33
+ Before upload to Spec Hub, the action parses JSON or YAML OpenAPI documents and adjusts **path operations** so collection generation is less likely to fail:
34
+
35
+ 1. **Missing `summary`:** Uses `operationId` if present; otherwise falls back to `METHOD /path` (for example `GET /pets`).
36
+ 2. **Very long `summary`:** Truncates to **200 characters** (with an ellipsis) so downstream limits are not exceeded.
37
+
38
+ This runs in `src/index.ts` before upload. If nothing under `paths` needs changing, the original document bytes are preserved. When normalization runs, the spec is re-serialized (JSON stays JSON; YAML stays YAML). Each fix emits a **warning** in the Actions log so you can improve the source spec over time. Invalid documents that cannot be parsed are left unchanged and a warning is logged.
39
+
40
+ ## Usage
41
+
42
+ ```yaml
43
+ jobs:
44
+ bootstrap:
45
+ runs-on: ubuntu-latest
46
+ permissions:
47
+ actions: write
48
+ contents: read
49
+ steps:
50
+ - uses: actions/checkout@v4
51
+ - uses: postman-cs/postman-bootstrap-action@v0
52
+ with:
53
+ project-name: core-payments
54
+ domain: core-banking
55
+ domain-code: AF
56
+ requester-email: owner@example.com
57
+ workspace-admin-user-ids: 101,102
58
+ spec-url: https://example.com/openapi.yaml
59
+ environments-json: '["prod","stage"]'
60
+ system-env-map-json: '{"prod":"uuid-prod","stage":"uuid-stage"}'
61
+ governance-mapping-json: '{"core-banking":"Core Banking"}'
62
+ postman-api-key: ${{ secrets.POSTMAN_API_KEY }}
63
+ postman-access-token: ${{ secrets.POSTMAN_ACCESS_TOKEN }}
64
+ github-token: ${{ secrets.GITHUB_TOKEN }}
65
+ gh-fallback-token: ${{ secrets.GH_FALLBACK_TOKEN }}
66
+
67
+ bootstrap-existing:
68
+ runs-on: ubuntu-latest
69
+ steps:
70
+ - uses: actions/checkout@v4
71
+ - uses: postman-cs/postman-bootstrap-action@v0
72
+ with:
73
+ project-name: core-payments
74
+ workspace-id: ws-123
75
+ spec-id: spec-123
76
+ baseline-collection-id: col-baseline
77
+ smoke-collection-id: col-smoke
78
+ contract-collection-id: col-contract
79
+ spec-url: https://example.com/openapi.yaml
80
+ postman-api-key: ${{ secrets.POSTMAN_API_KEY }}
81
+ ```
82
+
83
+ If you want the action to discover prior bootstrap state automatically on reruns, provide a `github-token` so it can read the stored repository variables before creating new Postman assets.
84
+
85
+ ## CLI Usage (Non-GitHub CI)
86
+
87
+ The CLI is available for GitLab CI, Bitbucket Pipelines, Azure DevOps, and other CI systems.
88
+ GitHub Actions users should continue using the `action.yml` interface.
89
+
90
+ Install globally:
91
+
92
+ ```bash
93
+ npm install -g postman-bootstrap-action
94
+ ```
95
+
96
+ Basic usage:
97
+
98
+ ```bash
99
+ postman-bootstrap \
100
+ --project-name core-payments \
101
+ --spec-url https://example.com/openapi.yaml \
102
+ --postman-api-key "$POSTMAN_API_KEY" \
103
+ --postman-access-token "$POSTMAN_ACCESS_TOKEN" \
104
+ --result-json bootstrap-result.json \
105
+ --dotenv-path bootstrap.env
106
+ ```
107
+
108
+ The CLI auto-detects the CI provider from environment variables for GitHub, GitLab, Bitbucket, and Azure DevOps.
109
+ It writes JSON to stdout, with all logs sent to stderr.
110
+ Use `--result-json` to write the JSON payload to a file, and `--dotenv-path` to emit shell-sourceable `KEY=VALUE` output with the `POSTMAN_BOOTSTRAP_` prefix.
111
+
112
+ Example GitLab CI job:
113
+
114
+ ```yaml
115
+ bootstrap:
116
+ image: node:20
117
+ script:
118
+ - npm install -g postman-bootstrap-action
119
+ - postman-bootstrap --project-name core-payments --spec-url "$SPEC_URL" --postman-api-key "$POSTMAN_API_KEY" --postman-access-token "$POSTMAN_ACCESS_TOKEN" --result-json bootstrap-result.json --dotenv-path bootstrap.env
120
+ artifacts:
121
+ paths:
122
+ - bootstrap-result.json
123
+ - bootstrap.env
124
+ ```
125
+
126
+ Example Bitbucket Pipelines step:
127
+
128
+ ```yaml
129
+ pipelines:
130
+ default:
131
+ - step:
132
+ image: node:20
133
+ script:
134
+ - npm install -g postman-bootstrap-action
135
+ - postman-bootstrap --project-name core-payments --spec-url "$SPEC_URL" --postman-api-key "$POSTMAN_API_KEY" --postman-access-token "$POSTMAN_ACCESS_TOKEN" --result-json bootstrap-result.json --dotenv-path bootstrap.env
136
+ artifacts:
137
+ - bootstrap-result.json
138
+ - bootstrap.env
139
+ ```
140
+
141
+ Example Azure DevOps job:
142
+
143
+ ```yaml
144
+ steps:
145
+ - task: NodeTool@0
146
+ inputs:
147
+ versionSpec: '20.x'
148
+ - script: |
149
+ npm install -g postman-bootstrap-action
150
+ postman-bootstrap --project-name core-payments --spec-url "$(SPEC_URL)" --postman-api-key "$(POSTMAN_API_KEY)" --postman-access-token "$(POSTMAN_ACCESS_TOKEN)" --result-json bootstrap-result.json --dotenv-path bootstrap.env
151
+ displayName: Bootstrap Postman assets
152
+ - publish: bootstrap-result.json
153
+ - publish: bootstrap.env
154
+ ```
155
+
156
+ ## Inputs
157
+
158
+ | Input | Default | Notes |
159
+ | --- | --- | --- |
160
+ | `workspace-id` | | Reuse an existing Postman workspace instead of creating one. |
161
+ | `spec-id` | | Update an existing Postman spec instead of uploading a new one. |
162
+ | `baseline-collection-id` | | Reuse an existing baseline collection. |
163
+ | `smoke-collection-id` | | Reuse an existing smoke collection. |
164
+ | `contract-collection-id` | | Reuse an existing contract collection. |
165
+ | `project-name` | | Service name used in workspace and asset naming. |
166
+ | `domain` | | Business domain used for governance assignment. |
167
+ | `domain-code` | | Short prefix used when constructing the workspace name. |
168
+ | `requester-email` | | Optional user invited into the workspace. |
169
+ | `workspace-admin-user-ids` | | Comma-separated Postman user IDs to grant admin access. |
170
+ | `spec-url` | | Required registry-backed OpenAPI document URL. |
171
+ | `environments-json` | `["prod"]` | Environment slugs preserved in outputs and repo variables. |
172
+ | `system-env-map-json` | `{}` | Map of environment slug to system environment ID. |
173
+ | `governance-mapping-json` | `{}` | Map of domain to governance group name. |
174
+ | `postman-api-key` | | Required for all Postman asset operations. |
175
+ | `postman-access-token` | | Required for governance assignment and canonical workspace validation during reruns. |
176
+ | `github-token` | | Enables repository variable persistence and rerun fallback discovery. |
177
+ | `gh-fallback-token` | | Optional fallback token for repository variable APIs. |
178
+ | `github-auth-mode` | `github_token_first` | Auth mode for repository variable APIs. |
179
+ | `integration-backend` | `bifrost` | Current public open-alpha backend. |
180
+
181
+ ### Obtaining `postman-api-key`
182
+
183
+ 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.
184
+
185
+ **To generate one:**
186
+
187
+ 1. Open the Postman desktop app or web UI.
188
+ 2. Go to **Settings** (gear icon) → **Account Settings** → **API Keys**.
189
+ 3. Click **Generate API Key**, give it a label, and copy the key (starts with `PMAK-`).
190
+ 4. Set it as a GitHub secret:
191
+ ```bash
192
+ gh secret set POSTMAN_API_KEY --repo <owner>/<repo>
193
+ ```
194
+
195
+ > **Note:** The PMAK is a long-lived key tied to your Postman account. It does not require periodic renewal like the `postman-access-token`.
196
+
197
+ ### Obtaining `postman-access-token` (Open Alpha)
198
+
199
+ > **⚠️ 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.
200
+
201
+ 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 governance group assignment and canonical workspace validation during reruns in this action. Without it, those steps degrade to warning-based behavior and name-based workspace fallback during provisioning.
202
+
203
+ **To obtain and configure the token:**
204
+
205
+ 1. **Log in via the Postman CLI** (requires a browser):
206
+ ```bash
207
+ postman login
208
+ ```
209
+ This opens a browser window for Postman's PKCE OAuth flow. Complete the sign-in.
210
+
211
+ 2. **Extract the access token** from the CLI credential store:
212
+ ```bash
213
+ cat ~/.postman/postmanrc | jq -r '.login._profiles[].accessToken'
214
+ ```
215
+
216
+ 3. **Set it as a GitHub secret** on your repository or organization:
217
+ ```bash
218
+ # Repository-level secret
219
+ gh secret set POSTMAN_ACCESS_TOKEN --repo <owner>/<repo>
220
+
221
+ # Organization-level secret (recommended for multi-repo use)
222
+ gh secret set POSTMAN_ACCESS_TOKEN --org <org> --visibility selected --repos <repo1>,<repo2>
223
+ ```
224
+ Paste the token value when prompted.
225
+
226
+ > **Important:** This token is session-scoped and will expire. When it does, operations that depend on it (governance and canonical workspace validation) degrade with warnings and fallback behavior. You will need to repeat the login and secret update process. There is no automated refresh mechanism.
227
+
228
+ > **Note:** `postman login --with-api-key` stores a PMAK — **not** the session token these APIs require. You must use the interactive browser login.
229
+
230
+ ## Outputs
231
+
232
+ - `workspace-id`
233
+ - `workspace-url`
234
+ - `workspace-name`
235
+ - `spec-id`
236
+ - `baseline-collection-id`
237
+ - `smoke-collection-id`
238
+ - `contract-collection-id`
239
+ - `collections-json`
240
+ - `lint-summary-json`
241
+
242
+ ## Local development
243
+
244
+ ```bash
245
+ npm install
246
+ npm test
247
+ npm run typecheck
248
+ npm run build
249
+ ```
250
+
251
+ `npm run build` produces the committed `dist/index.cjs` action bundle used by `action.yml`.
252
+
253
+ ## Open-Alpha Release Strategy
254
+
255
+ - Open-alpha channel tags use `v0.x.y`.
256
+ - Consumers can pin immutable tags such as `v0.2.0` for reproducibility.
257
+ - Moving tag `v0` is used only as the rolling open-alpha channel.
258
+
259
+ ## REST Migration Seam
260
+
261
+ Public inputs and outputs are backend-neutral. `integration-backend` currently supports `bifrost`, and backend-specific metadata stays internal so a future REST backend can replace the implementation without changing caller workflow syntax.
package/action.yml ADDED
@@ -0,0 +1,91 @@
1
+ name: postman-bootstrap-action
2
+ description: Public open-alpha action contract for Postman workspace, spec, and collection bootstrap.
3
+ inputs:
4
+
5
+ workspace-id:
6
+ description: Existing Postman workspace ID
7
+ required: false
8
+ spec-id:
9
+ description: Existing Postman spec ID
10
+ required: false
11
+ baseline-collection-id:
12
+ description: Existing baseline collection ID
13
+ required: false
14
+ smoke-collection-id:
15
+ description: Existing smoke collection ID
16
+ required: false
17
+ contract-collection-id:
18
+ description: Existing contract collection ID
19
+ required: false
20
+ project-name:
21
+ description: Service project name
22
+ required: true
23
+ domain:
24
+ description: Business domain for the service
25
+ required: false
26
+ domain-code:
27
+ description: Workspace naming prefix
28
+ required: false
29
+ requester-email:
30
+ description: Requester email for audit context
31
+ required: false
32
+ workspace-admin-user-ids:
33
+ description: Comma-separated workspace admin user ids
34
+ required: false
35
+ spec-url:
36
+ description: URL to the OpenAPI document to bootstrap
37
+ required: true
38
+ environments-json:
39
+ description: JSON array of environment slugs to preserve in bootstrap outputs
40
+ required: false
41
+ default: '["prod"]'
42
+ system-env-map-json:
43
+ description: JSON map of environment slug to system environment id
44
+ required: false
45
+ default: '{}'
46
+ governance-mapping-json:
47
+ description: JSON map of business domain to governance group name
48
+ required: false
49
+ default: '{}'
50
+ postman-api-key:
51
+ description: Postman API key used for bootstrap operations
52
+ required: true
53
+ postman-access-token:
54
+ description: Postman access token used for governance and workspace mutations
55
+ required: false
56
+ github-token:
57
+ description: GitHub token for repo variable persistence
58
+ required: false
59
+ gh-fallback-token:
60
+ description: Fallback token for repository variable APIs
61
+ required: false
62
+ github-auth-mode:
63
+ description: GitHub auth mode for repository variable APIs
64
+ required: false
65
+ default: github_token_first
66
+ integration-backend:
67
+ description: Integration backend for downstream workspace connectivity
68
+ required: false
69
+ default: bifrost
70
+ outputs:
71
+ workspace-id:
72
+ description: Postman workspace ID
73
+ workspace-url:
74
+ description: Postman workspace URL
75
+ workspace-name:
76
+ description: Postman workspace name
77
+ spec-id:
78
+ description: Uploaded Postman spec ID
79
+ baseline-collection-id:
80
+ description: Baseline collection ID
81
+ smoke-collection-id:
82
+ description: Smoke collection ID
83
+ contract-collection-id:
84
+ description: Contract collection ID
85
+ collections-json:
86
+ description: JSON summary of generated collections
87
+ lint-summary-json:
88
+ description: JSON summary of lint errors and warnings
89
+ runs:
90
+ using: node20
91
+ main: dist/index.cjs