メイン コンテンツにスキップ
CI/CD

自動ビルドおよびリリースアプリケーションにGithubアクションを使用

無料でGithubアクションを使用して独自のCI/CDパイプラインを作成し、Ionic Capacitor JSアプリケーションを毎回メインにプッシュするたびにデプロイ

マーティン・ドナディュー

マーティン・ドナディュー

コンテンツマーケター

自動ビルドおよびリリースアプリケーションにGithubアクションを使用

このチュートリアルはGitHubホスティングに焦点を当てていますが、他のCI/CDプラットフォームに適応するにはわずかな調整で使用できます。

序文

このチュートリアルでは、まずCapacitorアプリケーションをCapgoに追加してください。このチュートリアルはアップロードフェーズに焦点を当てています。 Capgoにアプリケーションを追加する必要がある場合は、このチュートリアルを参照してください。 チュートリアル

コミット規約

最初はコミット規約を遵守する必要があります conventional commits` これは、バージョン番号をアップグレードするためのツールの理解を助けるため、この5分で学べるものです。

Conventional Commits

GitHub アクションのタグ

次に、自動的にビルドおよびタグを作成するための最初の GitHub アクションを作成する必要があります。

ファイルを作成するパス: .github/workflows/bump_version.yml

この内容で:

name: Bump version

on:
  push:
    branches:
      - main

jobs:
  bump-version:
    if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with standard version"
    steps:
      - name: Check out
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
          filter: blob:none
          token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
      - name: Git config
        run: |
          git config --local user.name "github-actions[bot]"
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
      - name: Create bump and changelog
        run: npx capacitor-standard-version
      - name: Push to origin
        run: |
          CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
          remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
          git pull $remote_repo $CURRENT_BRANCH
          git push $remote_repo HEAD:$CURRENT_BRANCH --follow-tags --tags

これにより、メインブランチのすべてのコミットに対してタグをリリースし、メインブランチの各コミットに対して変更履歴エントリを追加します。 CHANGELOG.md.

このファイルが必要ない場合は心配しないでください。自動的に作成されます。

この機能を実現するには、 PERSONAL ACCESS TOKEN GitHubの個人アクセストークンを入力してください シークレット として PERSONAL_ACCESS_TOKEN.

CIがチェンジログをコミットすることを許可する必要があります。

トークンを作成するときは、有効期限を neverrepo.

スコープを package.json に選択してください

__CAPGO_KEEP_0__のファイルにバージョンを設定し、Nativeバージョン番号と同期してください。次のステップを容易にするためです。

You can now commit this both files and see your first tag appear in GitHub!

両方のネイティブプラットフォームとウェブプラットフォームは、各コミット後にバージョン番号を上げます。

GitHubのビルド用アクション

このパスにファイルを作成してください: .github/workflows/build.yml

この内容で:

name: Build source code and send to Capgo

on:
  push:
    tags:
      - '*'
      
jobs:
  deploy:
    runs-on: ubuntu-latest
    name: "Build code and release"
    steps:
      - name: Check out
        uses: actions/checkout@v6
      - name: Install dependencies
        id: install_code
        run: npm i
      - name: Build
        id: build_code
        run: npm run build
        env: # Remove both lines  if you don't need it
          FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }} # Example of env var coming from a secret
      - name: Create Release
        id: create_release
        run: npx @capgo/cli@latest bundle upload -a ${{ secrets.CAPGO_TOKEN }} -c production

これにより、依存関係をインストールしてビルドし、Capgoに送信します。

ビルド用のコマンドが異なります場合は、ステップを変更してください。 build_code これを実行するには、__CAPGO_KEEP_1__の__CAPGO_KEEP_0__キーを取得し、__CAPGO_KEEP_0__リポジトリのシークレットに追加する必要があります。

To make this work, you need to get your API key for Capgo, add it in the secret of your GitHub repository __CAPGO_KEEP_0__ CAPGO_TOKEN.

You can now commit this both files and see your first tag appear in GitHub!

__CAPGO_KEEP_0__

You should add your test in the build step to ensure your code is working.

Go to your Capgo dashboard and check your build who just appeared, you now have your CI/CD system.

If you want to let all of your users get the update whenever it’s available, go to your channel and set it to public.

You can also add the native build of your Ionic Capacitor JavaScript app by following this tutorial 👇

Keep going from Github Automatic build and release app

If you are using __CAPGO_KEEP_0__ Automatic build and release app with __CAPGO_KEEP_0__ actions Github Automatic build and release app with Github actions to plan CI/CD automation, connect it with __CAPGO_KEEP_0__ CI/CD for the product workflow in Capgo CI/CD Capgo Native Builds for the product workflow in Capgo Native Builds Capgo Capgo 連携 製品ワークフローにおける Capgo 連携の CI/CD 連携 CI/CD 連携の実装詳細について GitHub アクション連携 GitHub アクション連携の実装詳細について

Capacitor アプリ用リアルタイム更新

ウェブ層のバグが生じた場合、Capgo を使用して修正を配信するのではなく、アプリストアの承認待ちの日数を待たずに、ユーザーはバックグラウンドで更新を受け取り、ネイティブの変更は通常のレビュー経路を通る

スタートする

ブログの最新記事

Capgo を使用すると、プロフェッショナルなモバイルアプリを作成するために必要な最良の洞察を得ることができます。