> For AI agents: the complete documentation index is available at /ja/llms.txt, the full documentation bundle is available at /ja/llms-full.txt.

# 削除したブランチのDeploymentを削除する

GitHubのブランチを削除したとき、そのブランチに紐づくVercelの[Deployment](https://vercel.com/docs/glossary#deployment)を自動的に削除できます。

この機能は`delete`イベントかつ`cleanup-deployment`を`true`に設定しなければ有効になりません。

リポジトリの`.github/workflows/cleanup-deployments.yml`に、次のワークフローを作成してください。

```yaml file="/snippets/cleanup-workflow.yml"
name: Cleanup Vercel deployments

on:
  delete:

jobs:
  cleanup:
    if: ${{ github.event.ref_type == 'branch' }}
    name: Cleanup deployments
    runs-on: ubuntu-latest

    steps:
      - uses: nexterias/actions-vercel@v2
        with:
          token: ${{ secrets.VERCEL_TOKEN }}
          org-id: ${{ secrets.VERCEL_ORG_ID }}
          project-id: ${{ secrets.VERCEL_PROJECT_ID }}
          cleanup-deployment: true

```

このワークフローファイルは、リポジトリのデフォルトブランチに配置してください。

## 削除対象となるDeployment

- 指定したVercel Projectから、削除したGitHubブランチに紐づくDeploymentを削除します。
- [Production Deployment](https://vercel.com/docs/glossary#production-deployment)は削除しません。
- タグの削除では、このワークフローは実行されません。
