You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ef57d6c
Browse filesBrowse the repository at this point in the historyBrowse files
Run PR previews in a separate preview environment (#255)
The production environment now only deploys from main, so it rejects the
pull request refs that preview.yml runs on and the Preview job fails
before its first step. Point the job at a `preview` environment instead
and document which environment holds which credentials.
The secret and variable names are unchanged. The `preview` environment
is meant to hold a read-only GitHub App rather than the deploy App, the
follow-up noted in #238.
Claude-Session: https://claude.ai/code/session_016HDqNdz6KVjegQzqngoZKa
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+17-6Lines changed: 17 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,7 +120,7 @@ Channels listed in [`src/config/channels.ts`](src/config/channels.ts) are manage
120
120
### One-time setup
121
121
122
122
1. In the Cloudflare dashboard for the **MCP Domain Account**, create a token dedicated to Access policy role management. Give it a descriptive name so it does not read as a generic API token, e.g. `mcp-access: Access policy role management`, and scope it to only **Account → Access: Apps and Policies → Edit** on the MCP Domain Account. Do not reuse this token for anything else.
123
-
2. Add it as the GitHub Actions secret `CLOUDFLARE_ROLE_MANAGEMENT_TOKEN` in the `production`environment (repository settings → Environments → production). The deploy workflow passes it to Pulumi as `cloudflare:roleManagementToken`. Until the secret exists, the Cloudflare module logs "Cloudflare integration disabled: roleManagementToken not configured" and creates nothing, so previews stay green.
123
+
2. Add it as the GitHub Actions secret `CLOUDFLARE_ROLE_MANAGEMENT_TOKEN` in the `production`and `preview` environments (repository settings → Environments). The deploy workflow passes it to Pulumi as `cloudflare:roleManagementToken`. Until the secret exists, the Cloudflare module logs "Cloudflare integration disabled: roleManagementToken not configured" and creates nothing, so previews stay green.
124
124
3. The account ID and GitHub identity-provider ID are non-secret and live in [`Pulumi.prod.yaml`](Pulumi.prod.yaml).
125
125
4.**Adopting the existing policy.** Pulumi's `import` resource option only succeeds when the program's inputs match the live resource, so adoption is two deploys:
126
126
- With `cloudflare:importExistingPolicies: "true"` in `Pulumi.prod.yaml`, the first deploy imports the existing `Maintainers` policy (by its `cloudflarePolicyId`) as-is, ignoring its rule lists.
@@ -199,15 +199,26 @@ The private key is equivalent to organization admin. Store it as an environment
199
199
gh secret set DEPLOY_APP_PRIVATE_KEY --env production -R modelcontextprotocol/access < key.pem
200
200
```
201
201
202
+
Preview runs in the `preview` environment and reads `DEPLOY_APP_CLIENT_ID` and `DEPLOY_APP_PRIVATE_KEY` from there. That environment accepts pull request branches, so give it the credentials of a separate App that has only **Metadata: read** and **Custom organization roles: read**, not the deploy App's. The token Preview requests is limited to those two permissions, but the private key behind it is not.
203
+
202
204
Do not use a refresh (`make refresh`, `pulumi preview --refresh`) as a read-only check: the Discord member sync corrects role drift during `read()`, so any refresh can change live Discord roles.
203
205
204
206
### Required GitHub Secrets (for CI/CD)
205
207
206
-
The following secrets must be configured in GitHub Actions for automated deployments:
208
+
The workflows run in two GitHub environments (repository settings → Environments):
|`production`|[`deploy.yml`](.github/workflows/deploy.yml) on `main`|`main` only |
213
+
|`preview`|[`preview.yml`](.github/workflows/preview.yml) on pull requests | No restriction. Pull request runs use `refs/pull/<number>/merge`, which a `main`-only rule rejects. |
214
+
215
+
A secret or variable stored in an environment is visible only to jobs that declare that environment. One stored at repository level is visible to both. Anyone who can push a branch to this repository can run a workflow in `preview`, so keep the deploy App's private key out of it.
216
+
217
+
The following secrets must be configured in GitHub Actions for automated deployments. Both workflows read all of them. Apart from the App credentials, Preview needs the same values as Deploy: it fails without the billing email, and it shows the Discord and Cloudflare resources as deletes when their values are missing.
207
218
208
-
-**`DEPLOY_APP_PRIVATE_KEY`** (secret, `production`environment): private key of the deploy GitHub App
219
+
-**`DEPLOY_APP_PRIVATE_KEY`** (secret, set in each environment): private key of the deploy GitHub App in `production`, and of the read-only preview App in `preview`
209
220
210
-
-**`DEPLOY_APP_CLIENT_ID`** (a **variable**, not a secret, `production`environment): client ID of the deploy GitHub App
221
+
-**`DEPLOY_APP_CLIENT_ID`** (a **variable**, not a secret, set in each environment): client ID of the App whose private key that environment holds
211
222
212
223
-**`ORG_BILLING_EMAIL`**, **`DISCORD_BOT_TOKEN`**, **`DISCORD_GUILD_ID`**: passed to Pulumi config by the workflows
213
224
@@ -220,7 +231,7 @@ The following secrets must be configured in GitHub Actions for automated deploym
220
231
- Used to decrypt encrypted values in Pulumi stack configuration
221
232
- Keep this secure - if lost, you cannot decrypt your Pulumi state
222
233
223
-
-**`CLOUDFLARE_ROLE_MANAGEMENT_TOKEN`** (optional, `production`environment): Cloudflare token dedicated to Access policy role management, scoped only to **Account → Access: Apps and Policies → Edit** on the MCP Domain Account (not a general-purpose API token)
234
+
-**`CLOUDFLARE_ROLE_MANAGEMENT_TOKEN`** (optional, `production`and `preview` environments): Cloudflare token dedicated to Access policy role management, scoped only to **Account → Access: Apps and Policies → Edit** on the MCP Domain Account (not a general-purpose API token)
224
235
- Used to manage the Cloudflare Access policy for `securityroom.modelcontextprotocol.io` (see [Cloudflare Access (security-room)](#cloudflare-access-security-room))
225
236
226
237
## Initial Setup
@@ -284,4 +295,4 @@ Add the CI/CD secrets to GitHub Actions (repository settings → Secrets and var
284
295
285
296
-`GCP_PROD_SERVICE_ACCOUNT_KEY`: Content of `sa-key.json`
286
297
-`PULUMI_PROD_PASSPHRASE`: The passphrase you set above
287
-
-`DEPLOY_APP_CLIENT_ID` and `DEPLOY_APP_PRIVATE_KEY` (in the `production`environment, not at repository level): see [Deploy GitHub App](#deploy-github-app)
298
+
-`DEPLOY_APP_CLIENT_ID` and `DEPLOY_APP_PRIVATE_KEY` (in the `production`and `preview` environments, not at repository level): see [Deploy GitHub App](#deploy-github-app)
0 commit comments