feature: ReactからNext.jsへの転身、github workflowとk8sのマニフェストを追加、kuma-uiの導入 #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main # メインブランチへのプッシュ時にトリガー | |
| workflow_dispatch: # 手動でトリガー可能 | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. リポジトリコードをチェックアウト | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| # 2. Node.js 環境をセットアップ | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: "yarn" | |
| # 3. Yarn を使ってプロジェクトをインストール | |
| - name: Install Dependencies Using Yarn | |
| run: yarn install | |
| # 4. Next.js をビルド(SSG ページの生成) | |
| - name: Build Next.js App | |
| run: yarn build | |
| # 5. ユーザー名とリポジトリ名をフォーマットする | |
| - name: Format Username and Repository Name | |
| id: format | |
| run: | | |
| FORMATTED_USERNAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | |
| FORMATTED_REPO_NAME=$(echo "${{ github.event.repository.name }}" | sed -E 's/([a-z])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]') | |
| echo "FORMATTED_USERNAME=${FORMATTED_USERNAME}" >> $GITHUB_ENV | |
| echo "FORMATTED_REPO_NAME=${FORMATTED_REPO_NAME}" >> $GITHUB_ENV | |
| # 6. Docker にログイン(GitHub Container Registry) | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ env.FORMATTED_USERNAME }} | |
| password: ${{ secrets.GITHUB_TOKEN }} # GitHub Actions が自動提供するトークン | |
| # 7. Docker イメージをビルド | |
| - name: Build Docker Image | |
| run: | | |
| docker build -f infra/docker/Dockerfile . -t ghcr.io/${{ env.FORMATTED_USERNAME }}/${{ env.FORMATTED_REPO_NAME }}:latest | |
| # 8. Docker イメージをプッシュ | |
| - name: Push Docker Image | |
| run: | | |
| docker push ghcr.io/${{ env.FORMATTED_USERNAME }}/${{ env.FORMATTED_REPO_NAME }}:latest |