fix: Add Kubernetes namespace template and update devcontainer plugins #6
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. リポジトリ名と所有者名を変換 | |
| - name: Normalize Names | |
| id: normalize-names | |
| run: | | |
| # ユーザー名を小文字に変換 | |
| NORMALIZED_OWNER_NAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | |
| # github.repository からリポジトリ名部分のみを取り出し(/ 以降の部分) | |
| REPOSITORY_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) | |
| # 取り出したリポジトリ名をケバブケースに変換 | |
| NORMALIZED_REPOSITORY_NAME=$(echo "$REPOSITORY_NAME" | sed -E 's/([a-z])([A-Z])/\1-\L\2/g' | tr '[:upper:]' '[:lower:]') | |
| # 正規化した結果を出力(後続ステップで利用可能) | |
| echo "NORMALIZED_OWNER_NAME=${NORMALIZED_OWNER_NAME}" >> $GITHUB_ENV | |
| echo "NORMALIZED_REPOSITORY_NAME=${NORMALIZED_REPOSITORY_NAME}" >> $GITHUB_ENV | |
| # 4. Docker にログイン(GitHub Container Registry) | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/[email protected] | |
| with: | |
| registry: ghcr.io | |
| username: ${{ env.NORMALIZED_OWNER_NAME }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # 5. Docker イメージをビルド | |
| - name: Build Docker Image | |
| run: | | |
| docker build -f infra/docker/Dockerfile . \ | |
| -t ghcr.io/${{ env.NORMALIZED_OWNER_NAME }}/${{ env.NORMALIZED_REPOSITORY_NAME }}:latest | |
| # 6. Docker イメージをプッシュ | |
| - name: Push Docker Image | |
| run: | | |
| docker push ghcr.io/${{ env.NORMALIZED_OWNER_NAME }}/${{ env.NORMALIZED_REPOSITORY_NAME }}:latest |