Skip to content

GitHubアクションズ統合

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

前提条件

「前提条件」

Before setting up GitHub Actions integration, ensure you have:

  • A GitHub repository with your app’s source code
  • A Capgo account with an app configured
  • Node.jsとnpm/yarnがプロジェクトに設定されている
  • GitHub Actionsがリポジトリに有効

ステップ 1: リポジトリのシークレットの設定

「ステップ 1: リポジトリのシークレットの設定」のセクション

GitHub リポジトリに必要なシークレットを設定する

  1. GitHub リポジトリにアクセスする
  2. ここに移動する 設定シークレットと変数Actions
  3. クリック 新しいリポジトリのシークレット と次の値を追加します。
シークレット名
CAPGO_TOKENCapgo API のトークン

シンプルなプロダクション展開

「シンプルなプロダクション展開」

基本的な構成から始めましょう。主ブランチへのプッシュごとにプロダクションに展開します。

# Simple GitHub Actions Workflow for Capgo Live Updates
name: Deploy to Capgo
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install, test and build
run: |
npm ci
npm run test
npm run build
- name: Deploy to Capgo
run: |
npm install -g @capgo/cli
npx @capgo/cli bundle upload --channel production
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
# For encrypted uploads, add: --key-data-v2 "${{ secrets.CAPGO_PRIVATE_KEY }}"

高度なマルチチャネル構成

「高度なマルチチャネル構成」

機能ブランチの展開

「機能ブランチの展開」

機能ブランチをテスト用の仮想チャネルに展開します。

# Feature branch deployment
name: Deploy Feature Branch to Capgo
on:
push:
branches:
- 'feature/**'
jobs:
deploy-feature:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- run: |
npm ci
npm run test
npm run build
- name: Deploy to feature channel
run: |
CHANNEL_NAME=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')
npm install -g @capgo/cli
npx @capgo/cli channel create $CHANNEL_NAME --apikey ${{ secrets.CAPGO_TOKEN }} || true
npx @capgo/cli bundle upload --apikey ${{ secrets.CAPGO_TOKEN }} --channel $CHANNEL_NAME

暗号化の使用

「暗号化の使用」

あなたが Capgoの暗号化機能を使用している場合

あなたのプライベートキーを安全にCI/CD環境に保存する必要があります。 暗号化キーを GitHubのシークレットに追加する

ローカルに設定した後
# Display your private key content (copy this output)
cat .capgo_key_v2

コピー CAPGO_PRIVATE_KEY GitHubリポジトリのシークレットに追加するには、次の内容をコピーして貼り付けます。

# Deploy with encryption
- name: Deploy to Capgo with Encryption
run: |
npm install -g @capgo/cli
npx @capgo/cli bundle upload --apikey ${{ secrets.CAPGO_TOKEN }} --key-data-v2 "${{ secrets.CAPGO_PRIVATE_KEY }}" --channel production

複数の展開チャネルを設定して管理する方法については、チャンネルドキュメントを参照してください 開発、プルリクエスト、プロダクション展開の完全なワークフロー:.

クリップボードにコピー

# Complete multi-environment workflow
name: Deploy to Capgo
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- run: |
npm ci
npm run test
npm run build
- uses: actions/upload-artifact@v6
with:
name: dist
path: dist/
deploy-development:
if: github.ref == 'refs/heads/develop'
needs: build
runs-on: ubuntu-latest
environment: development
steps:
- uses: actions/setup-node@v6
with:
node-version: '24'
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- run: |
npm install -g @capgo/cli
npx @capgo/cli bundle upload --apikey ${{ secrets.CAPGO_TOKEN }} --channel development
deploy-pr:
if: github.event_name == 'pull_request'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v6
with:
node-version: '24'
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Deploy to PR channel
run: |
CHANNEL_NAME="pr-${{ github.event.number }}"
npm install -g @capgo/cli
npx @capgo/cli channel create $CHANNEL_NAME --apikey ${{ secrets.CAPGO_TOKEN }} || true
npx @capgo/cli bundle upload --apikey ${{ secrets.CAPGO_TOKEN }} --channel $CHANNEL_NAME
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 This PR has been deployed to Capgo channel: \`pr-${{ github.event.number }}\`\n\nTo test this update in your app, configure it to use this channel. [Learn how to configure channels →](/docs/live-updates/channels/#configuring-the-channel-in-your-app)`
})
deploy-production:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/setup-node@v6
with:
node-version: '24'
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- run: |
npm install -g @capgo/cli
npx @capgo/cli bundle upload --apikey ${{ secrets.CAPGO_TOKEN }} --channel production

機能チャンネルのクリーンアップ

Section titled “Cleanup Feature Channels”

ブランチが削除されたときに自動的に機能チャンネルをクリーンアップします:

name: Cleanup Feature Channels
on:
delete:
jobs:
cleanup:
runs-on: ubuntu-latest
if: github.event.ref_type == 'branch' && startsWith(github.event.ref, 'feature/')
steps:
- uses: actions/setup-node@v6
with:
node-version: '24'
- name: Delete Capgo channel
run: |
CHANNEL_NAME=$(echo "${{ github.event.ref }}" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')
npm install -g @capgo/cli
npx @capgo/cli channel delete $CHANNEL_NAME --apikey ${{ secrets.CAPGO_TOKEN }} || true

セキュリティとベストプラクティス

Section titled “Security and Best Practices”

GitHubで環境保護ルールを設定する

  1. Go to 設定環境 リポジトリ内
  2. 環境を作成する development, staging, production
  3. プロダクション環境の場合、次の項目を追加する
    • 必要なレビュアー: デプロイを承認する必要があるチームメンバーを追加する
    • : デプロイ前に待機時間を追加する (任意)Wait timer
    • 展開ブランチ: 限定 main ブランチのみ

環境固有のシークレットを使用:

# Use different secrets per environment
deploy-production:
environment: production
steps:
- name: Deploy to Production
run: |
npx @capgo/cli bundle upload \
--apikey ${{ secrets.CAPGO_PROD_TOKEN }} \
--app ${{ secrets.CAPGO_PROD_APP_ID }} \
--channel production

ワークフローにSlack通知を追加:

name: Deploy with Notifications
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# ... deployment steps
- name: Notify Slack on Success
if: success()
uses: 8398a7/action-slack@v3
with:
status: success
text: '✅ Capgo deployment successful!'
fields: repo,message,commit,author,action,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify Slack on Failure
if: failure()
uses: 8398a7/action-slack@v3
with:
status: failure
text: '❌ Capgo deployment failed!'
fields: repo,message,commit,author,action,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Discordに通知を送信:

- name: Discord notification
if: always()
uses: Ilshidur/action-discord@master
with:
args: |
Capgo deployment ${{ job.status }}!
App: ${{ secrets.CAPGO_APP_ID }}
Channel: ${{ github.ref_name }}
Commit: ${{ github.sha }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}

メール通知を設定:

- name: Send email notification
if: failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
subject: 'Capgo Deployment Failed - ${{ github.repository }}'
to: team@yourcompany.com
from: ci-cd@yourcompany.com
body: |
Deployment failed for ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Workflow: ${{ github.workflow }}

デバッグワークフロー

「デバッグ ワークフロー」

問題を解決するためのデバッグ ステップを追加します:

- name: Debug environment
run: |
echo "Node version: $(node --version)"
echo "NPM version: $(npm --version)"
echo "Working directory: $(pwd)"
echo "Files in dist/: $(ls -la dist/ || echo 'No dist directory')"
echo "Environment variables:"
env | grep -E "(GITHUB_|CAPGO_)" | sort
- name: Test Capgo CLI
run: |
npx @capgo/cli --version
npx @capgo/cli app debug --apikey ${{ secrets.CAPGO_TOKEN }} --app ${{ secrets.CAPGO_APP_ID }}

一般的な問題と解決策

「一般的な問題と解決策」

「CAPGO_TOKEN」が見つからないためワークフローが失敗します:

- name: Verify secrets
run: |
if [ -z "${{ secrets.CAPGO_TOKEN }}" ]; then
echo "ERROR: CAPGO_TOKEN secret is not set"
exit 1
fi
echo "CAPGO_TOKEN is set (length: ${#CAPGO_TOKEN})"
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}

ビルド アーティファクトが見つかりません:

- name: Debug artifacts
run: |
echo "Checking for build artifacts..."
ls -la dist/ || echo "No dist directory found"
find . -name "*.js" -o -name "*.html" | head -10

ネットワーク接続性の問題:

- name: Test connectivity
run: |
ping -c 3 api.capgo.io || echo "Ping failed"
curl -I https://api.capgo.io/health || echo "Health check failed"

再利用可能なワークフロー

「再利用可能なワークフロー」

プロジェクト間で一貫性を保つために、再利用可能なワークフローを作成します:

github/workflows/reusable-capgo-deploy.yml
name: Reusable Capgo Deploy
on:
workflow_call:
inputs:
environment:
required: true
type: string
channel:
required: true
type: string
secrets:
CAPGO_TOKEN:
required: true
CAPGO_APP_ID:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install and build
run: |
npm ci
npm run build
- name: Deploy to Capgo
run: |
npm install -g @capgo/cli
npx @capgo/cli bundle upload \
--apikey ${{ secrets.CAPGO_TOKEN }} \
--app ${{ secrets.CAPGO_APP_ID }} \
--channel ${{ inputs.channel }}

再利用可能なワークフローを使用します:

github/workflows/deploy.yml
name: Deploy App
on:
push:
branches: [main, develop]
jobs:
deploy-dev:
if: github.ref == 'refs/heads/develop'
uses: ./.github/workflows/reusable-capgo-deploy.yml
with:
environment: development
channel: development
secrets:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
CAPGO_APP_ID: ${{ secrets.CAPGO_APP_ID }}
deploy-prod:
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/reusable-capgo-deploy.yml
with:
environment: production
channel: production
secrets:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
CAPGO_APP_ID: ${{ secrets.CAPGO_APP_ID }}
  • 「次のステップ」 「チャンネル」 コンテキスト: Capgo リリースチャンネル機能名。ページ/エリア: Capgo ソリューションズマーケティングページ。役割: 短いUIラベルまたはナビゲーションアイテム。見られる場所: page solutions/white-label.astro。メッセージキー `solutions_white_label_visual_cell2_value` (Solutions White Label Visual Cell2 Value)。
  • 機能を探索 カスタムストレージ 高度なデプロイシナリオ向け
  • 設定 暗号化 セキュアなデプロイメント向け
  • 設定 更新動作 更新の適用方法をカスタマイズする

「GitHub Actions統合」機能を使用すると、GitHubの強力なCI/CDプラットフォームを活用して、Capgo Live Updatesの高度なデプロイワークフローを作成できます。このワークフローには、ビルトインのセキュリティ、監視、コラボレーション機能が含まれます。

「GitHub Actions統合」から続けて

「GitHub Actions統合」から続けて

Capgoを使用している場合 GitHub Actions統合 __CAPGO_KEEP_0__ CI/CD統合 Capgo CI/CD Capgo Nativeビルド Capgo Nativeビルド for the product workflow in Capgo Native Builds, Capgo CI/CD統合 for the product workflow in Capgo Integrations, CI/CD統合の実装詳細 GitLab CI/CD統合 CI/CD統合 GitLab CI/CD Integrationの実装詳細については、