> For the complete documentation index, see [llms.txt](https://help.genesis.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.genesis.autify.com/features-ja/workflow/github-webhook-trigger-context.md).

# GitHub Webhook トリガーのコンテキスト

GitHub Webhook を使用してワークフローを自動実行すると、トリガーとなった GitHub イベントのメタデータがコンテキストとして自動生成されます。本記事では、各イベントで渡されるコンテキストフィールドの一覧を説明します。

## コンテキストの動作

GitHub Webhook によってワークフローがトリガーされると、システムはイベントのペイロードからメタデータを抽出し、**トリガーコンテキスト**として構造化します。このコンテキストはワークフロー内の AI エージェントブロックのシステムプロンプトに自動的に付与されるため、AIは明示的な設定なしにトリガーのメタデータを参照できます。

## 全イベント共通フィールド

すべての GitHub Webhook イベントで常に渡されるフィールドです。

| フィールド名       | 説明                   | 例                               |
| ------------ | -------------------- | ------------------------------- |
| `event`      | トリガーとなったイベント種別       | `push`、`pull_request`、`release` |
| `repository` | リポジトリのフルネーム          | `owner/repo-name`               |
| `branch`     | ベースブランチ名             | `main`、`release/v2`             |
| `sender`     | イベントを発生させたユーザーのログイン名 | `username`                      |

{% hint style="info" %}
すべてのフィールドの値は文字列型として渡されます。数値（PR 番号など）も文字列で渡されます。
{% endhint %}

## イベント別フィールド

### プッシュ（push）

コードがブランチにプッシュされたときに渡される追加フィールドです。

| フィールド名          | 説明              | 例                                             |
| --------------- | --------------- | --------------------------------------------- |
| `commitSha`     | HEAD コミットの SHA  | `abc123def456...`                             |
| `commitMessage` | HEAD コミットのメッセージ | `Fix: ログイン処理を修正`                              |
| `commitUrl`     | HEAD コミットの URL  | `https://github.com/owner/repo/commit/abc123` |
| `commitCount`   | プッシュに含まれるコミット数  | `3`                                           |

### プルリクエスト（pull\_request）

プルリクエストが開かれた・更新された・閉じられたときに渡される追加フィールドです。

| フィールド名       | 説明                 | 例                                       |
| ------------ | ------------------ | --------------------------------------- |
| `action`     | PR に対して行われたアクション   | `opened`、`closed`、`synchronize`         |
| `prNumber`   | PR の番号             | `42`                                    |
| `prTitle`    | PR のタイトル           | `Feature: 新しいダッシュボード`                   |
| `prUrl`      | PR の URL           | `https://github.com/owner/repo/pull/42` |
| `headBranch` | PR のソースブランチ        | `feature/new-dashboard`                 |
| `baseBranch` | PR のターゲットブランチ      | `main`                                  |
| `headSha`    | PR の HEAD コミット SHA | `def456abc123...`                       |
| `merged`     | PR がマージ済みかどうか      | `true`、`false`                          |

### リリース（release）

新しいリリースが公開されたときに渡される追加フィールドです。

| フィールド名        | 説明                | 例                                                   |
| ------------- | ----------------- | --------------------------------------------------- |
| `action`      | リリースに対して行われたアクション | `published`、`created`、`edited`                      |
| `tagName`     | リリースのタグ名          | `v1.2.3`                                            |
| `releaseName` | リリースの名称           | `Version 1.2.3`                                     |
| `releaseUrl`  | リリースの URL         | `https://github.com/owner/repo/releases/tag/v1.2.3` |
| `prerelease`  | プレリリースかどうか        | `true`、`false`                                      |

## コンテキストの参照方法

AI エージェントブロックのシステムプロンプトには、以下のような形式でトリガーコンテキストが自動的に付与されます。

```
## Trigger Context
This workflow was automatically triggered. Here is the trigger metadata:
- **type**: github
- **event**: push
- **repository**: owner/repo-name
- **branch**: main
- **sender**: username
- **commitSha**: abc123def456...
- **commitMessage**: Fix: ログイン処理を修正
- **commitUrl**: https://github.com/owner/repo/commit/abc123
- **commitCount**: 1
```

AI エージェントブロックのプロンプトに「コミットメッセージを要約してください」と書くだけで、AI はコンテキストからコミット情報を自動的に参照できます。

## 関連ページ

* [ワークフローの実行](/features-ja/workflow/workflow-execution.md)
* [GitHub連携](/features-ja/resources-context/github-integration.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.genesis.autify.com/features-ja/workflow/github-webhook-trigger-context.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
