From fbad5fe6a43ce624da55fa9734fbf038781206b9 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Fri, 17 Jul 2026 09:49:55 -0600 Subject: [PATCH 1/5] docs(components): fix install_allow_scripts field name (install_allowInstallScripts never existed) Co-Authored-By: Claude Fable 5 --- reference/components/applications.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/components/applications.md b/reference/components/applications.md index 6bff5d15..dfc70cd3 100644 --- a/reference/components/applications.md +++ b/reference/components/applications.md @@ -213,7 +213,7 @@ Creates a new component project in the component root directory using a template - `template` _(optional)_ — Git URL of a template repository. Defaults to `https://github.com/HarperFast/application-template` - `install_command` _(optional)_ — Install command. Defaults to `npm install` - `install_timeout` _(optional)_ — Install timeout in milliseconds. Defaults to `300000` (5 minutes) -- `install_allowInstallScripts` _(optional)_ — Allow install scripts to run. Defaults to `false`, which causes `--ignore-scripts` to be passed to the install command (this is ignored with `install_command`). +- `install_allow_scripts` _(optional)_ — Allow install scripts to run. Defaults to `false`, which causes `--ignore-scripts` to be passed to the install command (this is ignored with `install_command`). - `replicated` _(optional)_ — Replicate to all cluster nodes ```json @@ -235,7 +235,7 @@ Deploys a component using a package reference or a base64-encoded `.tar` payload - `replicated` _(optional)_ — Replicate to all cluster nodes - `install_command` _(optional)_ — Install command override - `install_timeout` _(optional)_ — Install timeout override in milliseconds -- `install_allowInstallScripts` _(optional)_ — Allow install scripts to run. Defaults to `false`, which causes `--ignore-scripts` to be passed to the install command (this is ignored with `install_command`). +- `install_allow_scripts` _(optional)_ — Allow install scripts to run. Defaults to `false`, which causes `--ignore-scripts` to be passed to the install command (this is ignored with `install_command`). ```json { From a7cf04ecc14ff3812761f02d6602c6d4b66a54a7 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Fri, 17 Jul 2026 09:49:55 -0600 Subject: [PATCH 2/5] =?UTF-8?q?docs(learn):=20CI/CD=20deployment=20guide?= =?UTF-8?q?=20=E2=80=94=20git-tag=20vs=20registry,=20deploy=20credentials,?= =?UTF-8?q?=20GitHub=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- learn/developers/deploying-from-ci.mdx | 217 +++++++++++++++++++++++++ sidebarsLearn.ts | 5 + 2 files changed, 222 insertions(+) create mode 100644 learn/developers/deploying-from-ci.mdx diff --git a/learn/developers/deploying-from-ci.mdx b/learn/developers/deploying-from-ci.mdx new file mode 100644 index 00000000..ac1da5fe --- /dev/null +++ b/learn/developers/deploying-from-ci.mdx @@ -0,0 +1,217 @@ +--- +title: Deploying from a CI/CD Pipeline +--- + +Once an application is past the prototype stage, you want deployments to happen from your CI/CD pipeline, not from a laptop: a tag or release triggers a workflow, the workflow validates the code, and the pipeline tells your Harper cluster to deploy it. Harper's [`deploy_component`](/reference/v5/operations-api/operations#deploy_component) operation is a single HTTP call, so any CI system can drive it — this guide uses GitHub Actions and GitHub's hosting (repositories and the GitHub Packages npm registry), but the patterns translate directly to GitLab, Bitbucket, or any private npm registry. + +There are two ways to deliver an application to Harper, and choosing the right one is most of the battle: + +- **Deploy from a git tag** — Harper installs your application directly from a tagged commit in your repository. Best for applications that **run from source**. +- **Deploy from a package registry** — CI builds and publishes an artifact to a private npm registry; Harper installs that artifact by version. Best for applications that **need a build step**. + +Both work with private sources: `deploy_component` accepts a [`credentials`](/reference/v5/operations-api/operations#deploy-credentials-credentials) array carrying auth for a private git host or a private npm registry, backed by Harper's encrypted [secrets store](/reference/v5/security/secrets). + +## What You Will Learn + +- How to choose between git-tag deploys and registry-artifact deploys +- How to provision a deploy credential once and reference it from CI, so your pipeline never handles the GitHub token +- A GitHub Actions workflow that deploys a tagged release straight from a private repository +- A GitHub Actions workflow that builds, publishes to GitHub Packages, and deploys the published artifact +- How to deploy across a cluster and verify the deployment record + +## Prerequisites + +- A Harper Fabric cluster (or a self-managed Harper 5.2+ cluster with the Pro secrets component providing [custody](/reference/v5/security/secrets)) and a `super_user` credential for its Operations API +- A GitHub repository containing a working Harper application ([Create your First Application](../getting-started/create-your-first-application.mdx) if you don't have one) +- Familiarity with GitHub Actions basics (workflows, repository secrets) + +## Choosing a delivery model + +**Deploy from a git tag when your application runs from source.** Most Harper applications do: a `config.yaml`, a `schema.graphql`, resource classes in JavaScript (or TypeScript that Harper runs directly via type stripping), and npm dependencies that install cleanly. For these, the repository *is* the artifact. A git-tag deploy has no publish step to maintain — you tag a release, CI calls `deploy_component` with a reference like `github:my-org/my-app#semver:v1.2.3`, and every node installs exactly that commit. Semver-tagged references also keep the deployed version auditable: the deployment record and the component config both name the tag. + +**Deploy from a registry when your application needs a build.** If CI must produce output that isn't in the repository — a bundling step, compiled assets, code generation, native compilation — publish the *built* package to a registry and deploy that. This is better than making Harper build it for two reasons: + +1. **The artifact you tested is the artifact you run.** CI builds once, tests the result, publishes it. Every Harper node installs that identical, immutable artifact instead of re-running your build independently. +2. **No build scripts run on your database nodes.** When Harper installs a credentialed git reference, npm's pack step runs with `--ignore-scripts` by default, precisely so repository code can't run during install with the deploy credential in reach. A repository that *requires* a `prepare`/build script to be runnable forces you to set `install_allow_scripts: true`, which allows that script — and your dependencies' install scripts — to execute on the node during deployment. A registry artifact needs none of that: it's already built. + +A second constraint pushes the same direction: a git-reference deploy authenticates only the top-level repository. If your application has **private git-hosted dependencies** (a `package.json` dependency pointing at another private repo), their installation is not credentialed and will fail. Private *registry* dependencies work fine — registry credentials apply to the whole install. If your dependency graph reaches into private git repos, publish those dependencies (or the whole app) to a private registry instead. + +| Your application... | Deploy from | +| ------------------------------------------------------ | ---------------- | +| Runs from source (schema, resources, npm dependencies) | Git tag | +| Needs a build step (bundling, codegen, compilation) | Private registry | +| Has private git-hosted dependencies | Private registry | + +## Provision the deploy credential once + +Both paths need Harper to authenticate to GitHub — and it's worth understanding *when*. The credential is not only used at the moment you deploy: Harper persists it (encrypted, in the [secrets store](/reference/v5/security/secrets)) with the component's configuration so that later installs — a new node joining the cluster, a rollback, a re-install after restore — can fetch the package again without you re-supplying auth. + +That has one practical consequence: **use a durable token, not your workflow's ephemeral `GITHUB_TOKEN`**. The automatic `GITHUB_TOKEN` in a GitHub Actions run expires when the job ends. It's fine for things that happen *inside* the job (like publishing a package), but if you hand it to Harper as the deploy credential, any install that happens after the workflow finishes fails authentication. Instead, create a token whose lifetime matches how long nodes may need to fetch this component: + +- **For a private repository (git-tag deploys):** a GitHub [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with **Contents: read-only** permission, scoped to just the application repository. An organization can attach these to a machine account so they aren't tied to an individual. +- **For GitHub Packages (registry deploys):** a token with the **`read:packages`** scope. + +Store it in Harper once, granted to your component, using [`set_secret`](/reference/v5/operations-api/operations#set_secret): + +```json +{ + "operation": "set_secret", + "name": "gh-deploy-token", + "value": "github_pat_...", + "grants": ["my-app"] +} +``` + +From then on, CI references it by name — `{ "host": "github.com", "secret": "gh-deploy-token" }` — and the GitHub token never appears in your pipeline at all. The only secret your CI system holds is the Harper Operations API credential. This is the recommended setup: it separates the credential's lifecycle (rotate it with another `set_secret` call whenever you like — the deploy operation doesn't change) from the pipeline's. + +:::note Literal tokens +You can also pass the token inline: `{ "host": "github.com", "token": "github_pat_..." }`. Harper ingests it into the secrets store automatically (under a derived name like `deploy.my-app.git.github_com`) and the token is stripped from the operation before it is logged or replicated, so this is safe — re-deploying with a new token rotates the stored one. It just means your CI system holds the GitHub token too. Prefer the `secret` reference. +::: + +## Path A: deploy a tagged release from a private repository + +The flow: push a semver tag (`v1.2.3`) → the workflow calls `deploy_component` with a `#semver:` git reference → every node clones that tag and installs. + +Add two repository secrets to GitHub — `HARPER_OPS_URL` (your cluster's Operations API endpoint, e.g. `https://my-cluster.example.com:9925`) and `HARPER_OPS_AUTH` (a base64 `user:password` Basic credential or a bearer token for a `super_user`). Then: + +```yaml +# .github/workflows/deploy.yml +name: Deploy to Harper +on: + push: + tags: ['v*'] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Deploy tag to Harper + run: | + curl --fail-with-body -s "$HARPER_OPS_URL" \ + -H "Content-Type: application/json" \ + -H "Authorization: Basic $HARPER_OPS_AUTH" \ + -d @- <`) — useful if you want deploys keyed to commits rather than tags. +- **`replicated: true`** runs the deploy across the cluster; each node fetches and installs the package itself, resolving the credential from the (replicated) secrets store. +- **`restart: "rolling"`** restarts nodes sequentially so the cluster keeps serving throughout. Use `restart: true` for a single-node or dev instance. +- The token is served to git **from memory** on each node — it is never written into a URL, a lockfile, or a file on disk. + +If this repository needs a build step to be runnable, stop — don't reach for `install_allow_scripts`. Use Path B. + +## Path B: build in CI, publish to GitHub Packages, deploy the artifact + +The flow: push a tag → CI builds and tests → `npm publish` to GitHub Packages → `deploy_component` installs the published version from the registry. + +Your `package.json` needs a scoped name and a `publishConfig` pointing at GitHub Packages: + +```json +{ + "name": "@my-org/my-app", + "version": "1.2.3", + "publishConfig": { "registry": "https://npm.pkg.github.com" }, + "files": ["config.yaml", "schema.graphql", "dist/"] +} +``` + +Use `files` deliberately — it defines exactly what ships in the artifact. Then: + +```yaml +# .github/workflows/deploy.yml +name: Build, publish, and deploy to Harper +on: + push: + tags: ['v*'] + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: https://npm.pkg.github.com + - run: npm ci + - run: npm run build + - run: npm test + - name: Publish to GitHub Packages + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Deploy to Harper + run: | + VERSION="${GITHUB_REF_NAME#v}" + curl --fail-with-body -s "$HARPER_OPS_URL" \ + -H "Content-Type: application/json" \ + -H "Authorization: Basic $HARPER_OPS_AUTH" \ + -d @- <" +} +``` + +A useful pattern is to have the workflow poll [`get_deployment`](/reference/v5/operations-api/operations#get_deployment) until the deployment reaches `success` (or fail the job if it reports `failed`), so a broken deploy fails the pipeline rather than being discovered later. [`list_deployments`](/reference/v5/operations-api/operations#list_deployments) gives you the history — handy for answering "what exactly is deployed right now, and when did it change?" + +## Operational notes + +- **Rollback is just another deploy.** Both paths deploy immutable versions, so rolling back is re-running the deploy with the previous tag or version. This is a big part of why pinned references (`#semver:v1.2.3`, `@my-org/my-app@1.2.3`) beat branch references (`#main`) in a pipeline: `#main` moves, so you can neither audit nor re-deploy "what was running yesterday." +- **Rotating the deploy credential** is a `set_secret` call with the same name and new value — no change to the pipeline or the component. +- **Git-host credentials require git ≥ 2.31** on the Harper nodes, and are not supported on Windows nodes (the deploy fails with a clear error rather than degrading security). Registry credentials have no such constraints. Fabric instances satisfy both. +- **Self-managed OSS core without the Pro secrets component:** `secret` references can't be resolved (no decryption custody), and a literal `token` is used transiently for that node's install only — it is not persisted for later installs. The durable-credential patterns in this guide assume custody (Fabric provides it). + +## Additional Resources + +- [`deploy_component` and deploy credentials reference](/reference/v5/operations-api/operations#deploy_component) +- [Secrets store reference](/reference/v5/security/secrets) — the encrypted store behind `set_secret` and `secret` references +- [Deployment records](/reference/v5/operations-api/operations#deployment-operations) — `list_deployments`, `get_deployment` +- [Applications reference](/reference/v5/components/applications) — component structure and the full set of component operations +- [GitHub: fine-grained personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) +- [GitHub Packages: npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry) diff --git a/sidebarsLearn.ts b/sidebarsLearn.ts index 23b906d7..d266f53a 100644 --- a/sidebarsLearn.ts +++ b/sidebarsLearn.ts @@ -61,6 +61,11 @@ const sidebarsLearn: SidebarsConfig = { id: 'developers/write-through-caching', label: 'Write-Through Caching', }, + { + type: 'doc', + id: 'developers/deploying-from-ci', + label: 'Deploying from a CI/CD Pipeline', + }, ], }, { From 3754e6b3f98fae17981ed74f1263d3b0ba0e101f Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Fri, 17 Jul 2026 10:00:12 -0600 Subject: [PATCH 3/5] docs(learn): recommend inline token as the primary credential flow; mention Studio UI for set_secret Co-Authored-By: Claude Fable 5 --- learn/developers/deploying-from-ci.mdx | 28 ++++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/learn/developers/deploying-from-ci.mdx b/learn/developers/deploying-from-ci.mdx index ac1da5fe..e6187265 100644 --- a/learn/developers/deploying-from-ci.mdx +++ b/learn/developers/deploying-from-ci.mdx @@ -14,7 +14,7 @@ Both work with private sources: `deploy_component` accepts a [`credentials`](/re ## What You Will Learn - How to choose between git-tag deploys and registry-artifact deploys -- How to provision a deploy credential once and reference it from CI, so your pipeline never handles the GitHub token +- How to supply a deploy credential from CI — and why it must be a durable token, not the workflow's ephemeral `GITHUB_TOKEN` - A GitHub Actions workflow that deploys a tagged release straight from a private repository - A GitHub Actions workflow that builds, publishes to GitHub Packages, and deploys the published artifact - How to deploy across a cluster and verify the deployment record @@ -42,7 +42,7 @@ A second constraint pushes the same direction: a git-reference deploy authentica | Needs a build step (bundling, codegen, compilation) | Private registry | | Has private git-hosted dependencies | Private registry | -## Provision the deploy credential once +## Create a durable deploy token Both paths need Harper to authenticate to GitHub — and it's worth understanding *when*. The credential is not only used at the moment you deploy: Harper persists it (encrypted, in the [secrets store](/reference/v5/security/secrets)) with the component's configuration so that later installs — a new node joining the cluster, a rollback, a re-install after restore — can fetch the package again without you re-supplying auth. @@ -51,7 +51,11 @@ That has one practical consequence: **use a durable token, not your workflow's e - **For a private repository (git-tag deploys):** a GitHub [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with **Contents: read-only** permission, scoped to just the application repository. An organization can attach these to a machine account so they aren't tied to an individual. - **For GitHub Packages (registry deploys):** a token with the **`read:packages`** scope. -Store it in Harper once, granted to your component, using [`set_secret`](/reference/v5/operations-api/operations#set_secret): +Then hand it to Harper in one of two ways: + +**Pass it inline with the deploy (simplest — used in the workflows below).** Store the token as a repository secret in GitHub Actions and pass it in the `credentials` entry: `{ "host": "github.com", "token": "github_pat_..." }`. There is no separate provisioning step: Harper ingests the token into the encrypted secrets store on the way in (under a derived name like `deploy.my-app.git.github_com`, granted to the component), strips it from the operation before anything is logged or replicated, and reuses the stored copy for every later install. Re-deploying with a new token value rotates the stored one, so rotation is just updating the GitHub Actions secret. + +**Or provision it in Harper once, and reference it by name.** Create a secret with [`set_secret`](/reference/v5/operations-api/operations#set_secret) — or in [Harper Studio](/reference/v5/studio/overview), which provides a UI for creating, granting, and rotating secrets — granted to your component: ```json { @@ -62,17 +66,13 @@ Store it in Harper once, granted to your component, using [`set_secret`](/refere } ``` -From then on, CI references it by name — `{ "host": "github.com", "secret": "gh-deploy-token" }` — and the GitHub token never appears in your pipeline at all. The only secret your CI system holds is the Harper Operations API credential. This is the recommended setup: it separates the credential's lifecycle (rotate it with another `set_secret` call whenever you like — the deploy operation doesn't change) from the pipeline's. - -:::note Literal tokens -You can also pass the token inline: `{ "host": "github.com", "token": "github_pat_..." }`. Harper ingests it into the secrets store automatically (under a derived name like `deploy.my-app.git.github_com`) and the token is stripped from the operation before it is logged or replicated, so this is safe — re-deploying with a new token rotates the stored one. It just means your CI system holds the GitHub token too. Prefer the `secret` reference. -::: +CI then references it by name — `{ "host": "github.com", "secret": "gh-deploy-token" }` — and the GitHub token never appears in your pipeline at all; the only secret CI holds is the Harper Operations API credential. Choose this when you want the credential's lifecycle managed in Harper (or shared across pipelines) rather than living in each CI system's secrets. ## Path A: deploy a tagged release from a private repository The flow: push a semver tag (`v1.2.3`) → the workflow calls `deploy_component` with a `#semver:` git reference → every node clones that tag and installs. -Add two repository secrets to GitHub — `HARPER_OPS_URL` (your cluster's Operations API endpoint, e.g. `https://my-cluster.example.com:9925`) and `HARPER_OPS_AUTH` (a base64 `user:password` Basic credential or a bearer token for a `super_user`). Then: +Add three repository secrets to GitHub — `HARPER_OPS_URL` (your cluster's Operations API endpoint, e.g. `https://my-cluster.example.com:9925`), `HARPER_OPS_AUTH` (a base64 `user:password` Basic credential or a bearer token for a `super_user`), and `GH_DEPLOY_TOKEN` (the durable PAT from the previous section). Then: ```yaml # .github/workflows/deploy.yml @@ -95,7 +95,7 @@ jobs: "operation": "deploy_component", "project": "my-app", "package": "github:my-org/my-app#semver:${GITHUB_REF_NAME}", - "credentials": [{ "host": "github.com", "secret": "gh-deploy-token" }], + "credentials": [{ "host": "github.com", "token": "${GH_DEPLOY_TOKEN}" }], "replicated": true, "restart": "rolling" } @@ -103,6 +103,7 @@ jobs: env: HARPER_OPS_URL: ${{ secrets.HARPER_OPS_URL }} HARPER_OPS_AUTH: ${{ secrets.HARPER_OPS_AUTH }} + GH_DEPLOY_TOKEN: ${{ secrets.GH_DEPLOY_TOKEN }} ``` A few details worth noting: @@ -169,7 +170,7 @@ jobs: "project": "my-app", "package": "@my-org/my-app@${VERSION}", "credentials": [ - { "registry": "https://npm.pkg.github.com", "scope": "@my-org", "secret": "gh-packages-token" } + { "registry": "https://npm.pkg.github.com", "scope": "@my-org", "token": "${GH_PACKAGES_TOKEN}" } ], "replicated": true, "restart": "rolling" @@ -178,12 +179,13 @@ jobs: env: HARPER_OPS_URL: ${{ secrets.HARPER_OPS_URL }} HARPER_OPS_AUTH: ${{ secrets.HARPER_OPS_AUTH }} + GH_PACKAGES_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }} ``` Note the two tokens play different roles, matching their lifetimes: - **Publishing** uses the workflow's ephemeral `GITHUB_TOKEN` (with `packages: write`). Publishing happens entirely inside the job, so an ephemeral token is exactly right. -- **Installing** uses `gh-packages-token`, the durable `read:packages` secret you provisioned in Harper — because installs can happen long after this workflow ends. +- **Installing** uses `GH_PACKAGES_TOKEN`, the durable `read:packages` token — because installs can happen long after this workflow ends, and Harper stores this one for them. The `scope` field maps the `@my-org` scope to GitHub Packages on the installing node, so scoped dependencies from the same registry resolve too. @@ -203,7 +205,7 @@ A useful pattern is to have the workflow poll [`get_deployment`](/reference/v5/o ## Operational notes - **Rollback is just another deploy.** Both paths deploy immutable versions, so rolling back is re-running the deploy with the previous tag or version. This is a big part of why pinned references (`#semver:v1.2.3`, `@my-org/my-app@1.2.3`) beat branch references (`#main`) in a pipeline: `#main` moves, so you can neither audit nor re-deploy "what was running yesterday." -- **Rotating the deploy credential** is a `set_secret` call with the same name and new value — no change to the pipeline or the component. +- **Rotating the deploy credential**: with inline tokens, update the CI secret — the next deploy overwrites the stored copy. With a named secret, it's a `set_secret` call (or an edit in Harper Studio) with the same name and a new value; the pipeline doesn't change. - **Git-host credentials require git ≥ 2.31** on the Harper nodes, and are not supported on Windows nodes (the deploy fails with a clear error rather than degrading security). Registry credentials have no such constraints. Fabric instances satisfy both. - **Self-managed OSS core without the Pro secrets component:** `secret` references can't be resolved (no decryption custody), and a literal `token` is used transiently for that node's install only — it is not persisted for later installs. The durable-credential patterns in this guide assume custody (Fabric provides it). From bd847dc7c8e2ef040994a70201a1ce060472d544 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Sat, 18 Jul 2026 11:43:31 -0600 Subject: [PATCH 4/5] docs: fix prettier formatting in deploy-from-CI guide and operations reference CI's Format Check was failing on markdown table alignment and italic-marker style in these two files. Co-Authored-By: Claude Sonnet 5 --- learn/developers/deploying-from-ci.mdx | 16 ++++++++-------- reference/operations-api/operations.md | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/learn/developers/deploying-from-ci.mdx b/learn/developers/deploying-from-ci.mdx index e6187265..053c856f 100644 --- a/learn/developers/deploying-from-ci.mdx +++ b/learn/developers/deploying-from-ci.mdx @@ -27,26 +27,26 @@ Both work with private sources: `deploy_component` accepts a [`credentials`](/re ## Choosing a delivery model -**Deploy from a git tag when your application runs from source.** Most Harper applications do: a `config.yaml`, a `schema.graphql`, resource classes in JavaScript (or TypeScript that Harper runs directly via type stripping), and npm dependencies that install cleanly. For these, the repository *is* the artifact. A git-tag deploy has no publish step to maintain — you tag a release, CI calls `deploy_component` with a reference like `github:my-org/my-app#semver:v1.2.3`, and every node installs exactly that commit. Semver-tagged references also keep the deployed version auditable: the deployment record and the component config both name the tag. +**Deploy from a git tag when your application runs from source.** Most Harper applications do: a `config.yaml`, a `schema.graphql`, resource classes in JavaScript (or TypeScript that Harper runs directly via type stripping), and npm dependencies that install cleanly. For these, the repository _is_ the artifact. A git-tag deploy has no publish step to maintain — you tag a release, CI calls `deploy_component` with a reference like `github:my-org/my-app#semver:v1.2.3`, and every node installs exactly that commit. Semver-tagged references also keep the deployed version auditable: the deployment record and the component config both name the tag. -**Deploy from a registry when your application needs a build.** If CI must produce output that isn't in the repository — a bundling step, compiled assets, code generation, native compilation — publish the *built* package to a registry and deploy that. This is better than making Harper build it for two reasons: +**Deploy from a registry when your application needs a build.** If CI must produce output that isn't in the repository — a bundling step, compiled assets, code generation, native compilation — publish the _built_ package to a registry and deploy that. This is better than making Harper build it for two reasons: 1. **The artifact you tested is the artifact you run.** CI builds once, tests the result, publishes it. Every Harper node installs that identical, immutable artifact instead of re-running your build independently. -2. **No build scripts run on your database nodes.** When Harper installs a credentialed git reference, npm's pack step runs with `--ignore-scripts` by default, precisely so repository code can't run during install with the deploy credential in reach. A repository that *requires* a `prepare`/build script to be runnable forces you to set `install_allow_scripts: true`, which allows that script — and your dependencies' install scripts — to execute on the node during deployment. A registry artifact needs none of that: it's already built. +2. **No build scripts run on your database nodes.** When Harper installs a credentialed git reference, npm's pack step runs with `--ignore-scripts` by default, precisely so repository code can't run during install with the deploy credential in reach. A repository that _requires_ a `prepare`/build script to be runnable forces you to set `install_allow_scripts: true`, which allows that script — and your dependencies' install scripts — to execute on the node during deployment. A registry artifact needs none of that: it's already built. -A second constraint pushes the same direction: a git-reference deploy authenticates only the top-level repository. If your application has **private git-hosted dependencies** (a `package.json` dependency pointing at another private repo), their installation is not credentialed and will fail. Private *registry* dependencies work fine — registry credentials apply to the whole install. If your dependency graph reaches into private git repos, publish those dependencies (or the whole app) to a private registry instead. +A second constraint pushes the same direction: a git-reference deploy authenticates only the top-level repository. If your application has **private git-hosted dependencies** (a `package.json` dependency pointing at another private repo), their installation is not credentialed and will fail. Private _registry_ dependencies work fine — registry credentials apply to the whole install. If your dependency graph reaches into private git repos, publish those dependencies (or the whole app) to a private registry instead. | Your application... | Deploy from | | ------------------------------------------------------ | ---------------- | | Runs from source (schema, resources, npm dependencies) | Git tag | -| Needs a build step (bundling, codegen, compilation) | Private registry | -| Has private git-hosted dependencies | Private registry | +| Needs a build step (bundling, codegen, compilation) | Private registry | +| Has private git-hosted dependencies | Private registry | ## Create a durable deploy token -Both paths need Harper to authenticate to GitHub — and it's worth understanding *when*. The credential is not only used at the moment you deploy: Harper persists it (encrypted, in the [secrets store](/reference/v5/security/secrets)) with the component's configuration so that later installs — a new node joining the cluster, a rollback, a re-install after restore — can fetch the package again without you re-supplying auth. +Both paths need Harper to authenticate to GitHub — and it's worth understanding _when_. The credential is not only used at the moment you deploy: Harper persists it (encrypted, in the [secrets store](/reference/v5/security/secrets)) with the component's configuration so that later installs — a new node joining the cluster, a rollback, a re-install after restore — can fetch the package again without you re-supplying auth. -That has one practical consequence: **use a durable token, not your workflow's ephemeral `GITHUB_TOKEN`**. The automatic `GITHUB_TOKEN` in a GitHub Actions run expires when the job ends. It's fine for things that happen *inside* the job (like publishing a package), but if you hand it to Harper as the deploy credential, any install that happens after the workflow finishes fails authentication. Instead, create a token whose lifetime matches how long nodes may need to fetch this component: +That has one practical consequence: **use a durable token, not your workflow's ephemeral `GITHUB_TOKEN`**. The automatic `GITHUB_TOKEN` in a GitHub Actions run expires when the job ends. It's fine for things that happen _inside_ the job (like publishing a package), but if you hand it to Harper as the deploy credential, any install that happens after the workflow finishes fails authentication. Instead, create a token whose lifetime matches how long nodes may need to fetch this component: - **For a private repository (git-tag deploys):** a GitHub [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with **Contents: read-only** permission, scoped to just the application repository. An organization can attach these to a machine account so they aren't tied to an individual. - **For GitHub Packages (registry deploys):** a token with the **`read:packages`** scope. diff --git a/reference/operations-api/operations.md b/reference/operations-api/operations.md index b09fb850..034f6676 100644 --- a/reference/operations-api/operations.md +++ b/reference/operations-api/operations.md @@ -617,14 +617,14 @@ When a component is installed from a private source, `credentials` supplies the An entry provides its credential exactly one of two ways — a literal `token`, or a `secret` reference: -| Field | Kind | Description | -| ---------- | -------- | ------------------------------------------------------------------------------------------------ | -| `registry` | npm | The registry URL or host the credential applies to. **Required** for an npm entry. | -| `scope` | npm | Optional npm `@scope` (e.g. `"@my-org"`) the entry applies to; omit to set the default registry. | -| `host` | git | The bare git host the credential applies to (e.g. `"github.com"`). **Required** for a git entry. | -| `username` | git | Optional git HTTPS username. Defaults to `x-access-token` (GitHub); GitLab uses `oauth2`, Bitbucket `x-token-auth`. | -| `token` | both | A literal auth token, **or** | -| `secret` | both | The name of an [`hdb_secret`](../security/secrets.md) row to resolve the token from. | +| Field | Kind | Description | +| ---------- | ---- | ------------------------------------------------------------------------------------------------------------------- | +| `registry` | npm | The registry URL or host the credential applies to. **Required** for an npm entry. | +| `scope` | npm | Optional npm `@scope` (e.g. `"@my-org"`) the entry applies to; omit to set the default registry. | +| `host` | git | The bare git host the credential applies to (e.g. `"github.com"`). **Required** for a git entry. | +| `username` | git | Optional git HTTPS username. Defaults to `x-access-token` (GitHub); GitLab uses `oauth2`, Bitbucket `x-token-auth`. | +| `token` | both | A literal auth token, **or** | +| `secret` | both | The name of an [`hdb_secret`](../security/secrets.md) row to resolve the token from. | A provided **`token`** is not treated as ephemeral: Harper ingests it into the encrypted [secrets store](../security/secrets.md) and references it everywhere, so package-reference deploys keep working through rollback, reboot, and new peers joining — without re-supplying the token. The token is encrypted at rest, stripped from the operation before replication and from the operations log, and only ever crosses the cluster as ciphertext. A git-host token is additionally served to git **from memory** (via a credential helper) — it is never written to a file or into a URL. Using a **`secret`** reference names an existing store row directly. Ingesting a token requires custody on the deploying node; on OSS core without custody, a literal token falls back to a transient, this-node-only credential (not persisted or replicated). From d73e79a0c7f61d32b2673699df435b295c04ac58 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Mon, 20 Jul 2026 20:19:39 -0600 Subject: [PATCH 5/5] =?UTF-8?q?docs(learn):=20fix=20CI=20deploy=20guide=20?= =?UTF-8?q?review=20nits=20=E2=80=94=20auth=20header,=20secret=20name=20ty?= =?UTF-8?q?po?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HARPER_OPS_AUTH now documented (and used in the curl examples) as the full Authorization header value, so a Bearer token works as well as Basic — the hardcoded "Authorization: Basic $HARPER_OPS_AUTH" would break for bearer-token users. - Fix derived secret name example: deploy.my-app.git.github_com -> deploy.my-app.git.github.com (deriveGitSecretName preserves dots). Addresses review feedback from gemini-code-assist and cb1kenobi on PR #594. The heredoc-EOF-indentation concern raised alongside the auth header comments does not apply here: verified against a YAML parser that the block-scalar's common-indentation stripping puts EOF at column 0 in the actual generated script, since it shares curl's base indent. Co-Authored-By: Claude Sonnet 5 --- learn/developers/deploying-from-ci.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/learn/developers/deploying-from-ci.mdx b/learn/developers/deploying-from-ci.mdx index 053c856f..611852bd 100644 --- a/learn/developers/deploying-from-ci.mdx +++ b/learn/developers/deploying-from-ci.mdx @@ -53,7 +53,7 @@ That has one practical consequence: **use a durable token, not your workflow's e Then hand it to Harper in one of two ways: -**Pass it inline with the deploy (simplest — used in the workflows below).** Store the token as a repository secret in GitHub Actions and pass it in the `credentials` entry: `{ "host": "github.com", "token": "github_pat_..." }`. There is no separate provisioning step: Harper ingests the token into the encrypted secrets store on the way in (under a derived name like `deploy.my-app.git.github_com`, granted to the component), strips it from the operation before anything is logged or replicated, and reuses the stored copy for every later install. Re-deploying with a new token value rotates the stored one, so rotation is just updating the GitHub Actions secret. +**Pass it inline with the deploy (simplest — used in the workflows below).** Store the token as a repository secret in GitHub Actions and pass it in the `credentials` entry: `{ "host": "github.com", "token": "github_pat_..." }`. There is no separate provisioning step: Harper ingests the token into the encrypted secrets store on the way in (under a derived name like `deploy.my-app.git.github.com`, granted to the component), strips it from the operation before anything is logged or replicated, and reuses the stored copy for every later install. Re-deploying with a new token value rotates the stored one, so rotation is just updating the GitHub Actions secret. **Or provision it in Harper once, and reference it by name.** Create a secret with [`set_secret`](/reference/v5/operations-api/operations#set_secret) — or in [Harper Studio](/reference/v5/studio/overview), which provides a UI for creating, granting, and rotating secrets — granted to your component: @@ -72,7 +72,7 @@ CI then references it by name — `{ "host": "github.com", "secret": "gh-deploy- The flow: push a semver tag (`v1.2.3`) → the workflow calls `deploy_component` with a `#semver:` git reference → every node clones that tag and installs. -Add three repository secrets to GitHub — `HARPER_OPS_URL` (your cluster's Operations API endpoint, e.g. `https://my-cluster.example.com:9925`), `HARPER_OPS_AUTH` (a base64 `user:password` Basic credential or a bearer token for a `super_user`), and `GH_DEPLOY_TOKEN` (the durable PAT from the previous section). Then: +Add three repository secrets to GitHub — `HARPER_OPS_URL` (your cluster's Operations API endpoint, e.g. `https://my-cluster.example.com:9925`), `HARPER_OPS_AUTH` (the full `Authorization` header value for a `super_user` — `Basic ` or `Bearer `), and `GH_DEPLOY_TOKEN` (the durable PAT from the previous section). Then: ```yaml # .github/workflows/deploy.yml @@ -89,7 +89,7 @@ jobs: run: | curl --fail-with-body -s "$HARPER_OPS_URL" \ -H "Content-Type: application/json" \ - -H "Authorization: Basic $HARPER_OPS_AUTH" \ + -H "Authorization: $HARPER_OPS_AUTH" \ -d @- <