Automate Capacitor live updates with GitLab CI/CD
A copy-paste .gitlab-ci.yml that builds your web app and releases an OTA bundle with the OtaKit CLI on every pipeline — the GitLab equivalent of the GitHub Actions flow.
If your team lives in GitLab, you don't need GitHub Actions to automate Capacitor live updates. A short .gitlab-ci.yml can build your web app and release an over-the-air bundle with the OtaKit CLI on every pipeline. This guide is the GitLab equivalent of the GitHub Actions OTA flow.
Goal: a push to your main branch runs a pipeline that builds the web app and releases the bundle to a channel — no manual steps.
1. Add a masked CI/CD variable
Create a release token for your app and add it under Settings → CI/CD → Variables as OTAKIT_TOKEN. Mark it Masked (and Protected if you only release from protected branches) so it never appears in job logs.
2. Add the pipeline
This builds the web app and releases to production on the default branch. Adjust the build command and web directory to your framework:
# .gitlab-ci.yml
image: node:20
stages: [release]
release:
stage: release
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
cache:
paths: [node_modules/]
script:
- npm ci
- npm run build
- npm install -g @otakit/cli
- otakit upload --release production
# OTAKIT_TOKEN is injected from CI/CD variablesThe OtaKit CLI reads OTAKIT_TOKEN from the environment, so there's no interactive login. That's the whole pipeline for straight-to-production.
3. Stage before production
For user-facing apps, release to a pre-production channel automatically and promote by hand. Point the automated job at beta:
script:
- npm ci
- npm run build
- npm install -g @otakit/cli
- otakit upload --release betaThen promote the exact bundle you validated — no rebuild — when it looks healthy. See staged rollouts:
otakit release <bundle-id> --channel production
4. Promote on a tag
Prefer explicit promotions? Gate the production release on a tag pipeline instead of the default branch:
rules:
- if: '$CI_COMMIT_TAG =~ /^v/'Now merges flow to beta and tagging v1.4.2 ships production — your release history matches your tags.
Same rules as any OTA pipeline: mask the token, bump runtimeVersion on native changes, and fail the job if the build fails. See OTA security.
Where to go next
See the CI automation docs for tokens and flags, and automating channel promotion to make beta-to-production hands-off too.