-
Notifications
You must be signed in to change notification settings - Fork 0
ci(renovate): self-host Renovate via GitHub App to escape Mend Cloud OOM #2350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: renovate | ||
|
|
||
| permissions: {} | ||
|
|
||
| on: | ||
| schedule: | ||
| # 毎日 16:00 UTC = 翌 01:00 JST に起動。実際の PR 生成は .github/renovate.json5 の | ||
| # schedule / timezone(Asia/Tokyo) が gate する。この時刻なら | ||
| # - "before 11am on monday" → 月曜 01:00 JST でヒット | ||
| # - 四半期 "before 5am on the 1st" → 1日 01:00 JST でヒット | ||
| # の両方の窓を取りこぼさない(窓外の日は Renovate 側で no-op になるだけ)。 | ||
| - cron: "0 16 * * *" | ||
| workflow_dispatch: | ||
| inputs: | ||
| logLevel: | ||
| description: ログレベル | ||
| type: choice | ||
| default: info | ||
| options: [info, debug] | ||
| dryRun: | ||
| description: dry-run(書き込みなしでログ出力のみ) | ||
| type: boolean | ||
| default: false | ||
| # NOTE: `issues: edited` / `pull_request` トリガーは意図的に外している。Renovate 自身が | ||
| # Dependency Dashboard issue の body を毎回更新するため、これらを残すと | ||
| # 「run が dashboard を更新 → issues:edited が発火 → 別の run が起動」の自走ループになり | ||
| # 大量の `repository-changed` abort を生む。Dashboard checkbox を toggle しても次の | ||
| # scheduled / workflow_dispatch run で読み取られるので機能は失われない(即時反応しなくなるだけ)。 | ||
|
|
||
| concurrency: | ||
| group: renovate | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| renovate: | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 60 | ||
| # 実際の repo write 権限は GitHub App トークンが持つため job の GITHUB_TOKEN は不要。 | ||
| permissions: {} | ||
| steps: | ||
| # 専用 GitHub App の短命トークンを発行。GITHUB_TOKEN と異なり App トークンで | ||
| # 作成した PR は ci.yaml 等のワークフローを発火できる(automerge 前提のため必須)。 | ||
| - name: Generate GitHub App token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| with: | ||
| app-id: ${{ secrets.RENOVATE_APP_ID }} | ||
| private-key: ${{ secrets.RENOVATE_APP_PRIVATE_KEY }} | ||
|
|
||
| # self-host 実行。repo 設定 .github/renovate.json5 は Renovate が自動検出する | ||
| # (configurationFile はグローバル設定用なので渡さない)。 | ||
| - name: Self-hosted Renovate | ||
| uses: renovatebot/github-action@693b9ef15eec82123529a37c782242f091365961 # v46.1.14 | ||
| with: | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| env: | ||
| RENOVATE_REPOSITORIES: ${{ github.repository }} | ||
| RENOVATE_PLATFORM: github | ||
| # App トークンで GitHub Contents API 経由の commit を行う。commit は App bot に | ||
| # 自動帰属し "Verified" バッジが付くため、PAT 運用で必要だった gitAuthor 固定は不要。 | ||
| RENOVATE_PLATFORM_COMMIT: enabled | ||
| # Mend Cloud 無料枠は 3GB cap で OOM kill されていた。ubuntu-24.04 runner は | ||
| # 十分なメモリ(16GB)を持つので Renovate プロセス自身のヒープに 6GB 割り当てる。 | ||
| # pnpm 子プロセス側の上限は renovate.json5 の toolSettings.nodeMaxMemory(4096) が担保。 | ||
| NODE_OPTIONS: --max-old-space-size=6144 | ||
| LOG_LEVEL: ${{ inputs.logLevel || 'info' }} | ||
| # dryRun=true のとき 'full'、それ以外(schedule 実行含む)は空=通常実行。 | ||
| RENOVATE_DRY_RUN: ${{ inputs.dryRun && 'full' || '' }} | ||
| # schedule trigger 以外(workflow_dispatch)はユーザの能動的なアクションなので、 | ||
| # renovate.json5 の schedule を無視して即時実行する(force で schedule を空に上書き)。 | ||
| RENOVATE_FORCE: ${{ github.event_name != 'schedule' && '{"schedule":[]}' || '' }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Renovate self-host 移行 TODO(手動セットアップ) | ||
|
|
||
| Mend Cloud 無料枠(1 job = 3GB)の `kernel-out-of-memory` を回避するため、Renovate を | ||
| GitHub Actions の self-host(`.github/workflows/renovate.yaml`)へ移行した。runner は 16GB RAM の | ||
| ため Mend のメモリ上限から解放される。認証は短命トークンの **専用 GitHub App** を使う。 | ||
|
|
||
| このファイルは下記の手動ステップが完了したら削除すること。 | ||
|
|
||
| ## 背景(なぜ App 版か) | ||
|
|
||
| - 過去に PAT ベースの self-host 版が存在したが、全 Dependabot 化の際に削除 → その後 | ||
| 「Dependabot が pnpm 11 非対応」で npm を Renovate に差し戻した際、self-host を復活させず | ||
| Mend Cloud に戻ったため OOM が再発していた。 | ||
| - 今回は PAT より安全な GitHub App(短命トークン・`platformCommit` で Verified コミット)で再構築。 | ||
|
|
||
| --- | ||
|
|
||
| ## 手動ステップ(GitHub UI 操作のため要手動) | ||
|
|
||
| ### 1. 専用 GitHub App を作成 | ||
| GitHub → Settings → Developer settings → GitHub Apps → **New GitHub App** | ||
|
|
||
| - [ ] **Repository permissions** を設定 | ||
| - Contents: **Read and write**(ブランチ・コミット・lockfile 更新) | ||
| - Pull requests: **Read and write**(PR 作成・automerge 有効化) | ||
| - Issues: **Read and write**(Dependency Dashboard issue の維持) | ||
| - Metadata: Read-only(必須・自動付与) | ||
| - ※ `enabledManagers` は npm/mise/nvm のみでワークフローは触らないため **Workflows 権限は不要** | ||
| - [ ] **Webhook** の "Active" を **オフ**(cron / workflow_dispatch 起動なのでイベント購読不要) | ||
| - [ ] Where can this app be installed: **Only on this account** | ||
| - [ ] 作成後、**Private key を生成**(`.pem` をダウンロード)し、**App ID** を控える | ||
| - [ ] **Install App** で `s-hirano-ist/s-private` にインストール | ||
|
|
||
| ### 2. Secrets を登録 | ||
| ```bash | ||
| gh secret set RENOVATE_APP_ID --body "<App ID>" | ||
| gh secret set RENOVATE_APP_PRIVATE_KEY < ~/Downloads/<your-app>.private-key.pem | ||
| ``` | ||
| - [ ] `RENOVATE_APP_ID` 登録 | ||
| - [ ] `RENOVATE_APP_PRIVATE_KEY` 登録 | ||
|
|
||
| ### 3. リポジトリ設定 | ||
| - [ ] Settings → General → Pull Requests → **Allow auto-merge** を有効化 | ||
| (`platformAutomerge: true` の前提) | ||
|
|
||
| ### 4. Mend Renovate App を撤去(重複 PR 防止) | ||
| - [ ] GitHub → Settings → Integrations → Applications → **Renovate** → Configure → | ||
| `s-private` をアクセス対象から外す(または Uninstall) | ||
|
|
||
| --- | ||
|
|
||
| ## 検証(手動 1〜4 完了後) | ||
|
|
||
| - [ ] **dry-run**: `gh workflow run renovate.yaml -f dryRun=true -f logLevel=debug` | ||
| → Actions ログでリポジトリが処理され、OOM もエラーも無く完走することを確認 | ||
| - [ ] **本実行**: `gh workflow run renovate.yaml` → App ユーザーが `renovate/*` ブランチで | ||
| PR を作成し、`dependencies` ラベルが付くことを確認 | ||
| - [ ] **CI 連動**: 作成された Renovate PR 上で既存 `ci.yaml` が発火していることを確認 | ||
| (= App トークンがワークフローを起動できている証拠。`GITHUB_TOKEN` では起動しない) | ||
| - [ ] **automerge**: devDependencies / mise の patch・minor PR が CI 通過後に自動マージされ、 | ||
| main の branch protection と矛盾しないことを確認 | ||
| - [ ] **Dashboard**: Dependency Dashboard issue が self-host により更新されることを確認 | ||
| - [ ] **重複なし**: Mend 撤去後、Mend 由来の PR が新規に出ないことを数日観察 | ||
|
|
||
| --- | ||
|
|
||
| ## 後片付け | ||
|
|
||
| - [ ] 移行確認後、旧 PAT secret `RENOVATE_TOKEN` を削除(App 版では未使用) | ||
| `gh secret delete RENOVATE_TOKEN` | ||
| - [ ] Mend が残した既存の `renovate/*` リモートブランチを整理(self-host が作り直す) | ||
| - [ ] このファイル `renovate-todo.md` を削除 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントの RAM 表記が他ファイルと矛盾しています。
ここでは
ubuntu-24.04, 7GB RAMと記載していますが、.github/workflows/renovate.yaml(Line 63)とrenovate-todo.md(Line 4)はいずれも 16GB と記載しています。GitHub ホストの標準 Linux runner は 16GB です。NODE_OPTIONS=6144とnodeMaxMemory=4096を同時に与える OOM 回避の根拠に直結する数値なので、正しい値(16GB)に統一してください。📝 修正案
📝 Committable suggestion
🤖 Prompt for AI Agents