GitLab CI/CD¶
You can easily publish Live Updates to Capawesome Cloud using GitLab CI/CD. In this guide, we will show you how to create a GitLab CI/CD pipeline that builds your web assets and creates a bundle on Capawesome Cloud using the Capawesome CLI.
Preparation¶
Before you start, make sure you have a Capawesome Cloud account and an app set up. Next, you need to create a Capawesome Cloud token and add it to your GitLab project as a CI/CD variable.
Create a Capawesome Cloud token¶
Create a new Capawesome Cloud token via the Capawesome Cloud Console. Just navigate to the Tokens
page in the settings and click on the Create Token
button. Choose a name for the token and click on the Create
button. The token is now copied to your clipboard.
Create a GitLab CI/CD Variable¶
Add the Capawesome Cloud token to your GitLab project as a CI/CD variable with the name CAPAWESOME_CLOUD_TOKEN
as described in CI/CD variables. Make sure to mark the variable as masked and protected.
Pipeline¶
Create the Pipeline¶
Create a new GitLab CI/CD pipeline file in your repository under .gitlab-ci.yml
with the following content:
spec:
inputs:
channel:
description: The name of the channel to deploy the update to.
default: production
---
stages:
- deploy
deploy-live-update:
stage: deploy
image: node:20
before_script:
- npm ci
- npm run build
- npm install -g @capawesome/cli@latest
script:
- npx @capawesome/cli apps:channels:create --appId 00000000-0000-0000-0000-000000000000 --name $[[ inputs.channel ]] --ignore-errors
- npx @capawesome/cli apps:bundles:create --appId 00000000-0000-0000-0000-000000000000 --path dist --channel $[[ inputs.channel ]]
This pipeline will build your web assets, log in to Capawesome Cloud (using the CAPAWESOME_CLOUD_TOKEN
environment variable), create a channel (if it does not exist yet), and create a bundle for the specified channel.
Trigger the Pipeline¶
You can run the pipeline manually by navigating to the CI/CD
> Pipelines
section in your GitLab project and clicking on the Run pipeline
button. You will be prompted to enter the channel name as a variable. Of course, you can also trigger the pipeline automatically by using different rules like push
or merge_request
.