Point your CI at a PocketHost instance and every push deploys your pb_hooks, pb_migrations, pb_public, and packages. You need two things:
POCKETHOST_TOKEN.pockethost and runs pockethost deploy.No password, SSH key, or saved login is needed, so it works on fresh CI runners.
Go to Account → API Tokens and click Create token:
GitHub Actions.Copy the token (pbt_…) right away. PocketHost stores only a hash of it, so it is shown once.
In GitHub: Settings → Secrets and variables → Actions → New repository secret. Name it POCKETHOST_TOKEN and paste the token.
main to one instanceRun pockethost link https://my-app.pockethost.io in your project once and commit .pocketbase/remotes.json, so the workflow knows which instance to deploy to:
# .github/workflows/deploy.yml
name: Deploy to PocketHost
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: curl -fsSL https://pockethost.io/install.sh | sh
- run: pockethost deploy --restart
env:
POCKETHOST_TOKEN: ${{ secrets.POCKETHOST_TOKEN }} --restart restarts the instance when the deploy changed migrations or packages, so they apply.
Create one instance per branch you care about (for example myapp-main and myapp-staging), give the token access to those instances, then deploy to the instance’s URL instead of a linked remote:
name: Deploy branch
on:
push:
branches: [main, staging]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: curl -fsSL https://pockethost.io/install.sh | sh
- run: pockethost deploy https://myapp-${{ github.ref_name }}.pockethost.io --restart
env:
POCKETHOST_TOKEN: ${{ secrets.POCKETHOST_TOKEN }} A push to a branch whose instance doesn’t exist, or isn’t in the token’s scope, fails the deploy.
One token covers every instance in its scope, so all your branches share the same POCKETHOST_TOKEN secret. If POCKETHOST_TOKEN isn’t set, pockethost falls back to P1_TOKEN.
pockethost hashes your project files and sends the list to your instance.--restart).What gets deployed:
pb_hooks/, pb_migrations/, pb_public/, and other top-level pb_* folderspackage.json, bun.lock, bun.lockb, and patches/node_modules/, when there’s a package.json (see npm packages)What never gets touched:
pb_data/ (your database and uploaded files).git* filesYour project is the source of truth. A deploy makes the instance’s code match your project, so files on the instance that aren’t in your project are removed. If you’ve changed hooks on the instance directly, copy those changes into your repo before the first CI deploy (pockethost pull brings them down).
PocketHost doesn’t run npm install. Instead, pockethost deploy ships your production node_modules when there’s a package.json: the packages in dependencies and everything they need, never devDependencies. In CI, install before you deploy (npm ci or bun install). See Packages.
PocketBase’s JavaScript engine has no Node.js built-ins, so packages that use them (fs, crypto, Buffer) won’t run there. Packages that only ship ES modules won’t load either, since it only understands CommonJS. For one of those, bundle it into a single file in pb_hooks with a bundler such as esbuild (--bundle --format=cjs --platform=neutral) and require() that file.
Any CI that can run a shell works the same way: set POCKETHOST_TOKEN as a secret environment variable, install pockethost with curl -fsSL https://pockethost.io/install.sh | sh (or download it from Releases), and run pockethost deploy.
pbt_ (older ones with ph_pat_), which makes a leaked one easy to search for in logs and code.The token was revoked, has expired, or was pasted with a typo, or POCKETHOST_TOKEN isn’t set in the step’s env. Create a new token and update the secret.
Create a token with Deploy + read access, and check that its instance list includes the instance. To add an instance, click Edit on the token at Account → API Tokens.
Migrations or packages changedDeploy with --restart, or run pockethost restart afterwards.