Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions docs/setup-gitlab.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ git push -u origin main

> Instance レベルのテンプレートには管理者権限が必要で、GitLab.com では利用できません。すべての環境で Group テンプレートを推奨します。

> **Free tier**: Group project templates は Premium 以上のプランが必要です。Free tier の場合はこの手順をスキップし、代わりに `scripts/create-gitlab-project.sh` を使用してください — 下記の[プロジェクトごと(Free Tier)](#プロジェクトごとfree-tier)を参照。

### 3. Template Project に Template Sync を設定

Template Project は GitHub から同期して最新の状態を保ちます。この設定は **Template Project にのみ**行います — 個々の GAS プロジェクトには不要です。
Expand Down Expand Up @@ -76,6 +78,8 @@ cd <your-project>
pnpm install
```

> **Free tier**: 「Create from template」が利用できない場合は、下記の [Free Tier](#プロジェクトごとfree-tier) ワークフローを使用してください。

### 2. Script ID の設定

`.clasp-dev.json` と `.clasp-prod.json` を作成(gitignore 済み):
Expand Down Expand Up @@ -137,6 +141,58 @@ pnpm run check # lint + 型チェック + テスト

User Project の Runner は `github.com` への接続が不要です。外部アクセス(または社内ミラー)が必要なのは Template Project の Runner のみです。

## プロジェクトごと(Free Tier)

GitLab Free tier では「Create from template」(Group project templates)が利用できません。代わりに `scripts/create-gitlab-project.sh` を使用してプロジェクトを作成します。

### 前提条件

- [glab CLI](https://gitlab.com/gitlab-org/cli) が対象 GitLab ホストに認証済み
- apps-script-fleet テンプレートリポジトリのローカルクローン

### 1. プロジェクトの作成

テンプレートリポジトリのルートから実行:

```bash
./scripts/create-gitlab-project.sh --group my-org --name my-gas-project
```

新しい GitLab リポジトリが作成され、テンプレートファイルがコピーされ、初回コミットが push されます。

オプション:

| フラグ | 説明 | デフォルト |
| ----------------- | -------------------------------------------- | ---------------- |
| `--group` | GitLab group または namespace(必須) | |
| `--name` | リポジトリ名(必須) | |
| `--hostname` | GitLab ホスト名 | 自動検出 |
| `--visibility` | `private`、`internal`、`public` | `private` |
| `--description` | プロジェクトの説明 | |

### 2. GAS プロジェクトの初期化と CI/CD 設定

```bash
cd ../my-gas-project
pnpm install
./scripts/init.sh --title "My Script" [--gcp-project <NUMBER>]
```

### 3. Template Sync の設定

1. **Project Access Token** を作成(Settings → Access Tokens、`write_repository` スコープ)
2. CI/CD Variable として `GITLAB_PUSH_TOKEN` の名前で追加
3. `TEMPLATE_REPO_URL` を CI/CD Variable として追加し、テンプレートリポジトリの git URL を指定(例: `https://gitlab.yourcompany.com/my-org/apps-script-fleet.git`)。または Group レベルで設定
4. **Pipeline Schedule** を作成(CI/CD → Schedules)— 例: 毎週日曜

### 4. 確認とデプロイ

```bash
pnpm run check # lint + 型チェック + テスト
```

`dev` への push で dev 環境へ、`main` への push で本番環境へ自動デプロイされます。

## 既存環境からの移行

従来のインポート/クローン方式で作成したプロジェクトは影響を受けません。既存の Template Sync 設定はそのまま独立して動作します。新しいモデルへの移行は任意です:
Expand Down
56 changes: 56 additions & 0 deletions docs/setup-gitlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Then register it as a **[Group project template](https://docs.gitlab.com/user/gr

> Instance-level templates require admin privileges and are not available on GitLab.com. Group templates are recommended for all environments.

> **Free tier**: Group project templates require Premium or higher. If you are on the Free tier, skip this step and use `scripts/create-gitlab-project.sh` instead — see [Per Project (Free Tier)](#per-project-free-tier) below.

### 3. Configure Template Sync on the Template Project

The Template Project syncs from GitHub to stay up to date. Configure this on the **Template Project only** — individual GAS projects do not need this.
Expand Down Expand Up @@ -76,6 +78,8 @@ cd <your-project>
pnpm install
```

> **Free tier**: If "Create from template" is not available, use the [Free Tier](#per-project-free-tier) workflow below instead.

### 2. Set your script IDs

Create `.clasp-dev.json` and `.clasp-prod.json` (gitignored):
Expand Down Expand Up @@ -137,6 +141,58 @@ Push to `dev` triggers dev deployment, push to `main` triggers production deploy

User Project runners never need to reach `github.com`. Only the Template Project's runner needs external access (or an internal mirror).

## Per Project (Free Tier)

On GitLab Free tier, "Create from template" (Group project templates) is not available. Use `scripts/create-gitlab-project.sh` to create projects from the template instead.

### Prerequisites

- [glab CLI](https://gitlab.com/gitlab-org/cli) authenticated for your GitLab host
- A local clone of the apps-script-fleet template repository

### 1. Create the project

From the template repository root:

```bash
./scripts/create-gitlab-project.sh --group my-org --name my-gas-project
```

This creates a new GitLab repository, copies template files, and pushes the initial commit.

Options:

| Flag | Description | Default |
| ----------------- | --------------------------------------------------- | --------------- |
| `--group` | GitLab group or namespace (required) | |
| `--name` | Repository name (required) | |
| `--hostname` | GitLab hostname | auto-detect |
| `--visibility` | `private`, `internal`, or `public` | `private` |
| `--description` | Project description | |

### 2. Initialize GAS projects and CI/CD

```bash
cd ../my-gas-project
pnpm install
./scripts/init.sh --title "My Script" [--gcp-project <NUMBER>]
```

### 3. Set up Template Sync

1. Create a **Project Access Token** (Settings → Access Tokens) with `write_repository` scope
2. Add it as a CI/CD Variable named `GITLAB_PUSH_TOKEN`
3. Add `TEMPLATE_REPO_URL` as a CI/CD Variable pointing to the template repository's git URL (e.g., `https://gitlab.yourcompany.com/my-org/apps-script-fleet.git`), or set it at the Group level for all projects
4. Create a **Pipeline Schedule** (CI/CD → Schedules) — e.g., weekly on Sunday

### 4. Verify and deploy

```bash
pnpm run check # lint + typecheck + test
```

Push to `dev` triggers dev deployment, push to `main` triggers production deployment.

## Migration from Existing Setup

Existing projects created via the old import/clone method are unaffected. Their per-project Template Sync configuration continues to work independently. Migration to the new model is optional:
Expand Down
Loading
Loading