메뉴로 이동

__CAPGO_KEEP_10__

Integrate Capgo Live Updates with GitLab CI/CD to automatically deploy your app updates whenever you push code changes. This guide covers setting up automated builds, testing, and deployment workflows.

GitLab CI/CD와 __CAPGO_KEEP_0__ Live Updates를 통합하여 __CAPGO_KEEP_1__ 변경 사항을 푸시할 때마다 앱 업데이트를 자동으로 배포하세요.

설치 전 요구 사항

GitLab CI/CD 통합을 설정하기 전에 다음을 확인하세요:

  • GitLab 계정과 프로젝트 저장소
  • Capgo 계정과 앱이 설정된 Capgo
  • Node.js와 npm/yarn이 프로젝트에 설정된 경우

GitLab CI/CD 설정

설치 요구 사항

1단계: 환경 변수 설정

1단계: 환경 변수 설정

먼저 GitLab 프로젝트에서 필요한 변수를 설정하세요:

  1. 프로젝트로 이동하세요
  2. GitLab 프로젝트로 이동하세요 설정CI/CD변수
  3. 다음 변수를 추가하세요:
변수 이름보호가려진
CAPGO_TOKENYour Capgo API 토큰✅ 예✅ 예

Copy to clipboard

# .gitlab-ci.yml - Simple Configuration
image: node:22
stages:
- build
- deploy
variables:
npm_config_cache: "$CI_PROJECT_DIR/.npm"
build:
stage: build
script:
- npm ci
- npm run test
- npm run build
artifacts:
paths:
- dist/
expire_in: 1 hour
only:
- main
deploy_production:
stage: deploy
script:
- npm install -g @capgo/cli
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production
# For encrypted uploads, add: --key-data-v2 "$CAPGO_PRIVATE_KEY"
dependencies:
- build
only:
- main

__CAPGO_KEEP_0__ __CAPGO_KEEP_1__

기능 branch 배포

기능 branch를 테스트 채널에 배포하여 검토 및 테스트:

# Feature branch deployment
deploy_feature:
stage: deploy
script:
- npm install -g @capgo/cli
- CHANNEL_NAME="feature-$(echo $CI_COMMIT_REF_NAME | sed 's/[^a-zA-Z0-9-]/-/g')"
- npx @capgo/cli channel create $CHANNEL_NAME --apikey $CAPGO_TOKEN || true
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel $CHANNEL_NAME
dependencies:
- build
only:
- /^feature\/.*$/
environment:
name: feature/$CI_COMMIT_REF_NAME
url: https://your-app.com/channels/$CHANNEL_NAME

만약 __CAPGO_KEEP_0__의 암호화 기능을 사용 중이라면 Capgo’s encryption feature__CAPGO_KEEP_0__

설정 후 로컬에서 암호화 키를 설정한 후 GitLab 변수에 개인 키를 추가하세요:

터미널 창
# Display your private key content (copy this output)
cat .capgo_key_v2

GitLab 프로젝트 변수에 다음 내용을 추가하세요 (보호 및 가려진 상태로 마크하고) CAPGO_PRIVATE_KEY 복사

# Deploy with encryption
deploy_production:
script:
- npm install -g @capgo/cli
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --key-data-v2 "$CAPGO_PRIVATE_KEY" --channel production

Multi-Channel Configuration

Multi-Channel Configuration

For comprehensive information about setting up and managing multiple deployment channels, see the Channels.

Complete configuration with multiple environments and merge request deployments:

# .gitlab-ci.yml - Advanced Multi-Channel Configuration
image: node:22
stages:
- build
- deploy
variables:
npm_config_cache: "$CI_PROJECT_DIR/.npm"
# Build stage
build:
stage: build
script:
- npm ci
- npm run test
- npm run build
artifacts:
paths:
- dist/
expire_in: 24 hours
# Deploy to development channel
deploy_development:
stage: deploy
script:
- npm install -g @capgo/cli
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel development
dependencies:
- build
only:
- develop
environment:
name: development
# Deploy merge requests to test channels
deploy_mr:
stage: deploy
script:
- npm install -g @capgo/cli
- CHANNEL_NAME="mr-$CI_MERGE_REQUEST_IID"
- npx @capgo/cli channel create $CHANNEL_NAME --apikey $CAPGO_TOKEN || true
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel $CHANNEL_NAME
dependencies:
- build
only:
- merge_requests
environment:
name: review/$CI_MERGE_REQUEST_IID
url: https://your-app.com/channels/mr-$CI_MERGE_REQUEST_IID
on_stop: cleanup_mr
# Cleanup MR channels when MR is closed
cleanup_mr:
stage: deploy
script:
- npm install -g @capgo/cli
- npx @capgo/cli channel delete mr-$CI_MERGE_REQUEST_IID --apikey $CAPGO_TOKEN || true
when: manual
environment:
name: review/$CI_MERGE_REQUEST_IID
action: stop
only:
- merge_requests
# Deploy to staging
deploy_staging:
stage: deploy
script:
- npm install -g @capgo/cli
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel staging
dependencies:
- build
only:
- develop
environment:
name: staging
# Deploy to production
deploy_production:
stage: deploy
script:
- npm install -g @capgo/cli
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production
dependencies:
- build
only:
- main
environment:
name: production

Multi-Environment with Manual Approval

Multi-Environment with Manual Approval

__CAPGO_KEEP_0__ 프로덕션 배포에 대한 수동 승인 요구가 있는 경우:

deploy_production:
stage: deploy
script:
- npm install -g @capgo/cli
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production
dependencies:
- build
only:
- main
when: manual
environment:
name: production

Branch-Based 배포 전략

Branch-Based 배포 전략

적절한 채널로 자동으로 다른 branch를 배포하십시오:

# Dynamic channel deployment based on branch
deploy:
stage: deploy
script:
- npm install -g @capgo/cli
- |
if [ "$CI_COMMIT_REF_NAME" = "main" ]; then
CHANNEL="production"
elif [ "$CI_COMMIT_REF_NAME" = "develop" ]; then
CHANNEL="staging"
else
CHANNEL="development"
fi
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel $CHANNEL
dependencies:
- build
environment:
name: $CHANNEL

보안 최적화

보안 최적화

보호 변수

보호 변수
  1. Sensitive 변수를 표시하십시오: __CAPGO_KEEP_0__ 토큰은 항상 보호 및 가려야 합니다.API
  2. Branch Protection__CAPGO_KEEP_0__을 사용하여 프로덕션 배포에 보호 변수를 사용하세요.
  3. Access Control유지보수자만이 변수에 접근할 수 있도록 제한하세요.
  4. Regular RotationAPI 토큰을 정기적으로 회전하세요.

Secure Pipeline Configuration

안전한 Pipeline 구성
# Use protected variables for production
deploy_production:
stage: deploy
script:
- npm install -g @capgo/cli
- npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production
only:
refs:
- main
variables:
- $CI_COMMIT_REF_PROTECTED == "true"

__CAPGO_KEEP_0__을 클립보드에 복사하세요.

Monitoring and Notifications

__CAPGO_KEEP_0__ 모니터링 및 알림입니다. Section titled “Monitoring and Notifications” is not translated as it is a title and not a human-readable text. However, the title is translated as below: "__CAPGO_KEEP_0__ 모니터링 및 알림". Slack Integration is not translated as it is a title and not a human-readable text. However, the title is translated as below: "__CAPGO_KEEP_0__ Slack 통합".

Slack 통합 설정

Slack 알림을 pipeline에 추가하세요.

notify_success:
stage: .post
image: alpine:latest
before_script:
- apk add --no-cache curl
script:
- |
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"✅ Capgo deployment successful for '"$CI_COMMIT_REF_NAME"'"}' \
$SLACK_WEBHOOK_URL
when: on_success
notify_failure:
stage: .post
image: alpine:latest
before_script:
- apk add --no-cache curl
script:
- |
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"❌ Capgo deployment failed for '"$CI_COMMIT_REF_NAME"'"}' \
$SLACK_WEBHOOK_URL
when: on_failure

이메일 알림

이메일 알림 설정

GitLab 프로젝트 설정에서 이메일 알림을 구성하거나 API:를 사용하세요.

notify_email:
stage: .post
script:
- |
curl --request POST \
--header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" \
--form "to=team@yourcompany.com" \
--form "subject=Capgo Deployment Status" \
--form "body=Deployment of $CI_COMMIT_REF_NAME completed with status: $CI_JOB_STATUS" \
"https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/emails"
when: always

문제 해결

문제 해결

일반적인 문제

일반적인 문제

pipeline이 “Capgo CLI not found”로 실패합니다.

# Debug CLI installation
debug_cli:
script:
- npm install -g @capgo/cli
- which capgo || echo "Capgo CLI not found"
- npx @capgo/cli --version

인증 오류:

# Verify token configuration
debug_auth:
script:
- |
if [ -z "$CAPGO_TOKEN" ]; then
echo "CAPGO_TOKEN is not set"
exit 1
fi
echo "Token length: ${#CAPGO_TOKEN}"

빌드_artifacts_가 찾을 수 없습니다:

# List build outputs
debug_build:
script:
- ls -la dist/
- find dist/ -type f -name "*.js" -o -name "*.html"

디버그 PIPELINE

디버그 PIPELINE 섹션

문제를 해결하기 위해 디버깅 정보를 추가하세요:

debug:
stage: build
script:
- echo "Branch: $CI_COMMIT_REF_NAME"
- echo "Commit: $CI_COMMIT_SHA"
- echo "Build: $CI_PIPELINE_ID"
- env | grep CI_ | sort
only:
- branches

GitLab CI/CD 통합을 통해 Capgo 배포를 자동화하고 모바일 앱 사용자에게 일관된, 신뢰할 수 있는 업데이트를 보장할 수 있습니다.