GitHub Agentic Workflow について学習しました。そのメモです。
主たるコマンドは以下のページ参照。
実務上、ワークフローをgh aw add-wizard githubnext/agentics/<workflow name>で取り込むのが便利。以下にあるワークフローを取り込んでくれます。
前提
私の環境は、Ubuntu で動かしています。
公式に記載の以下が前提です。
- AI アカウント: GitHub Copilot、 Anthropic Claude、 OpenAI Codex、Google Gemini
- 書き込みアクセス権がある GitHub リポジトリ
- GitHub Actions リポジトリに対して有効
- GitHub CLI (gh) v2.0.0 以降がインストールおよび認証されている
- バージョンを確認するには、 gh --versionを実行します。 認証するには、次のコマンドを実行します。
CLIに関しては以下のコマンドでインストール/Update可能。
# GitHub CLI (gh)
sudo apt update
sudo apt install gh
# GitHub Agentic Workflows CLI (gh-aw)
gh extension upgrade github/gh-aw --force
# バージョン確認
gh --version
gh aw version
Quick Start: まずは使う
まずは、Quick Start を実施。
1. ワークフロー追加
ワークフロー追加前にRepositoryのGit状態をCommit しておく。gh aw add-wizardでgithubnext/agenticsからワークフローを追加。
$ gh aw add-wizard githubnext/agentics/daily-repo-status
→ Welcome to GitHub Agentic Workflows!
This tool will walk you through adding an automated workflow to your repository.
✓ Target repository: yfukuhara_microsoft/ghaw-test
✓ Working directory is clean
✓ Selected engine: copilot
i Could not confirm org Copilot CLI billing — check with your org admin.
i A fine-grained PAT with Copilot Requests permission will be required.
⚠ COPILOT_GITHUB_TOKEN already exists, but GitHub does not expose stored secret values for validation.
i Paste the current or replacement fine-grained PAT so gh aw can validate it and update the repository secret.
Create a fine-grained Personal Access Token (PAT) from the preconfigured page below, then paste it back here.
Preconfigured token creation page:
$ https://github.com/settings/personal-access-tokens/new?name=COPILOT_GITHUB_TOKEN&user_copilot_requests=read
✓ Valid fine-grained Copilot token received
✓ Uploaded COPILOT_GITHUB_TOKEN secret to repository
The following workflow files will be added:
• .github/workflows/daily-repo-status.md
• .github/workflows/daily-repo-status.lock.yml
i This workflow runs on a schedule.
途中 PAT(personal access tokens)をブラウザでGenerateしてCLIに入力(最小権限として Copilot Requests: Read だけを付ける)。PATのIDはCOPILOT_GITHUB_TOKENでなくても問題ない。IDがCOPILOT_GITHUB_TOKENなのはリポジトリシークレット側(Agentic Workflow で固定値のような形で使われるので)。
2. ワークフロー起動
コマンドでワークフローを起動。
$ gh workflow run
? Select a workflow Repo Status (daily-repo-status.lock.yml)
? aw_context
✓ Created workflow_dispatch event for daily-repo-status.lock.yml at main
https://github.com/yfukuhara_microsoft/ghaw-test/actions/runs/31565522579
To see the created workflow run, try: gh run view 31565522579
To see runs for this workflow, try: gh run list --workflow="daily-repo-status.lock.yml"
aw_context入力を聞かれていますが、未入力でEnter。以下で定義されている通り、required: falseで今回は不要。
on:
schedule:
- cron: "41 21 * * *" # Friendly format: daily (scattered)
workflow_dispatch:
inputs:
aw_context:
default: ""
description: "Agent caller context (used internally by Agentic Workflows)."
required: false
type: string
もし、手で./.github/workflows/my-workflow.mdを修正したら以下のコマンド実行。
gh aw compile
独自のワークフロー定義
次は、自分自身でワークフローを定義していきます。
1. 初期化
gh aw initで初期化。
$ gh aw init
→ Welcome to GitHub Agentic Workflows!
This tool will initialize your repository for GitHub Agentic Workflows.
i Setting up repository...
✓ Repository initialized for agentic workflows!
i To create a workflow, see https://github.github.com/gh-aw/setup/creating-workflows
i Or add an example workflow, see https://github.com/githubnext/agentics
以下のディレクトリ、ファイルが作成されます。
├── .gitattribute
├── .github
│ └── skills
│ └── agentic-workflows
│ └── SKILL.md
└── .vscode
└── settings.json
2. 追加
gh aw newでワークフロー定義を追加。Interactiveにいくつか聞かれます。
# 名前
$ gh aw new
┃ What should we call this workflow?
┃ Enter a descriptive name for your workflow (e.g., 'issue-triage', 'code-review-helper')
┃ > my-workflow
# 設定(トリガーとAI Engine)
Basic Configuration
Let's start with the fundamentals of your workflow
When should this workflow run?
Choose the GitHub event that triggers this workflow
> Manual trigger (workflow_dispatch)
Issue opened or reopened
Pull request opened or synchronized
Push to main branch
Issue comment created
Schedule (daily, scattered execution time)
┃ Which AI engine should process this workflow?
┃ The AI engine interprets instructions and executes tasks using available tools
┃ > copilot - GitHub Copilot CLI
┃ claude - Anthropic Claude Code coding agent
┃ codex - OpenAI Codex engine
┃ gemini - Google Gemini CLI
# Tool と 許可アクション
Capabilities
Select the tools and outputs your workflow needs
Which tools should the AI have access to?
Tools enable the AI to interact with code, APIs, and external systems
> [•] github - GitHub API tools (issues, PRs, comments, repos)
[ ] edit - File editing tools
[ ] bash - Shell command tools
[ ] web-fetch - Web content fetching tools
[ ] web-search - Web search tools
[ ] playwright - Browser automation tools
┃ What outputs should the AI be able to create?
┃ Safe outputs allow the AI to create GitHub resources after human approval
┃ > [•] create-issue - WRITE-ONCE: do NOT call this tool with empty or placeholder arguments to probe or discover its schema — required field…
┃ [ ] create-agent-session - Create a GitHub Copilot coding agent session to delegate coding work
┃ [ ] create-discussion - Create a GitHub discussion for announcements, Q&A, reports, status updates, or community conversations
┃ [ ] update-discussion - Update an existing GitHub discussion's title, body, and/or labels
┃ [ ] close-discussion - Close a GitHub discussion with a resolution comment and optional reason
┃ [ ] close-issue - Close a GitHub issue with a closing comment
┃ [ ] close-pull-request - Close a pull request WITHOUT merging, adding a closing comment
┃ [ ] add-comment - WRITE-ONCE: do NOT call this tool with empty or placeholder arguments to probe or discover its schema — the required `…
# Network
# ecosystem を選ぶと PythonであればPyPIなどへアクセスする
Network & Security
Configure network access and security settings
┃ What network access does the workflow need?
┃ Network access controls which external domains the workflow can reach
┃ > defaults - Basic infrastructure only
┃ ecosystem - Common development ecosystems (Python, Node.js, Go, etc.)
で、最後に以下の内容を入力。
# デイリー・リポジトリ状況レポート
直近24時間のリポジトリ状況を確認し、1件の Issue にまとめてください。
確認する内容:
* コミット
* オープン中の Issue
* オープン中の Pull Request
* レビュー待ちの Pull Request
* 失敗している GitHub Actions
重要な内容だけを簡潔にまとめてください。
Issue タイトル:
`Daily Repository Status - YYYY-MM-DD`
同じ日付の Issue がある場合は、新しく作成せず既存 Issue を更新してください。
リポジトリへの変更は、この Issue の作成・更新だけにしてください。
$ gh aw new
Created new workflow: /home/fukuhara/repositories/investigation/ghaw-test/.github/workflows/my-workflow.md
⠧ Compiling your workflow...✓ .github/workflows/my-workflow.md (103.0 KB)
⠇ Compiling your workflow...✓ Compiled 1 workflow: 1 succeeded, 0 warnings
✓ Workflow compiled successfully!
i You can now find your compiled workflow at .github/workflows/my-workflow.lock.yml
./.github/workflows/に2つのファイルが作成されます。
$ ls -al ./.github/workflows/
total 116
drwxr-xr-x 2 fukuhara fukuhara 4096 Aug 12 17:17 .
drwxr-xr-x 5 fukuhara fukuhara 4096 Aug 12 17:17 ..
-rw-r--r-- 1 fukuhara fukuhara 105485 Aug 12 17:17 my-workflow.lock.yml
-rw------- 1 fukuhara fukuhara 1588 Aug 12 17:17 my-workflow.md
ワークフロー定義の中身。
---
on:
workflow_dispatch:
permissions:
contents: read
issues: read
pull-requests: read
engine: copilot
network: defaults
tools:
github:
toolsets: [default]
safe-outputs:
create-issue:
---
# my-workflow
# デイリー・リポジトリ状況レポート
直近24時間のリポジトリ状況を確認し、1件の Issue にまとめてください。
確認する内容:
* コミット
* オープン中の Issue
* オープン中の Pull Request
* レビュー待ちの Pull Request
* 失敗している GitHub Actions
重要な内容だけを簡潔にまとめてください。
Issue タイトル:
`Daily Repository Status - YYYY/MM/DD`
同じ日付の Issue がある場合は、新しく作成せず既存 Issue を更新してください。
リポジトリへの変更は、この Issue の作成・更新だけにしてください。
3. ワークフロー定義修正
ワークフロー定義を修正してみます。
Issue タイトル:
`Daily Repository Status - YYYY-MM-DD`
Issue タイトル:
`Daily Repository Status - YYYY/MM/DD`
コンパイルを実施。
gh aw compile
4. 実行前確認
4.1. ドライラン
試行のドライラン。この場合はRepositoryも作らない。
$ gh aw trial ./.github/workflows/my-workflow.md --dry-run
→ Welcome to GitHub Agentic Workflows!
This tool will run a trial of your workflow in a test repository.
i [DRY RUN] Showing what would be done without making changes
i Starting trial of workflow 'my-workflow' from ''
i Target repository (current): YoheiFukuhara/ghaw-test
i Host repository (default): YoheiFukuhara/gh-aw-trial
════════════════════════════════════════════════════════════════════════════════
Trial Execution Plan
════════════════════════════════════════════════════════════════════════════════
│ Workflow: my-workflow (from )
│ Target: YoheiFukuhara/ghaw-test (simulated)
│ Mode: Simulate execution against target repository
│ Host Repo: YoheiFukuhara/gh-aw-trial
│ https://github.com/YoheiFukuhara/gh-aw-trial
│ Cleanup: Host repository will be preserved
════════════════════════════════════════════════════════════════════════════════
Execution Steps
════════════════════════════════════════════════════════════════════════════════
i 1. Create a private host repository
i 2. Install and compile my-workflow
i 3. Execute my-workflow
i 4. Preserve the host repository for inspection
i ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4.2. 試行
今度はドラインランではなく試行実行。試行用にリポジトリを作成しておく必要があり、少し面倒。検証用なら不要だが、本番リポジトリで試す前の確認としては必要。
そして以下が必要。そして、やはりSecret COPILOT_GITHUB_TOKENも必要。
- Trial用に作成された/指定したリポジトリの Settings タブでActions -> Generalを選択
- Under 'Workflow permissions', select 'Allow GitHub Actions to create and approve pull requests'
- Click 'Save'
パスを間違えたので、失敗だが、コマンドgh aw trial ./.github/workflows/my-workflow.md。
$ gh aw trial ./my-workflow.md
→ Welcome to GitHub Agentic Workflows!
This tool will run a trial of your workflow in a test repository.
i Starting trial of workflow 'my-workflow' from ''
i Target repository (current): YoheiFukuhara/ghaw-test
i Host repository (default): YoheiFukuhara/gh-aw-trial
════════════════════════════════════════════════════════════════════════════════
Trial Execution Plan
════════════════════════════════════════════════════════════════════════════════
│ Workflow: my-workflow (from )
│ Target: YoheiFukuhara/ghaw-test (simulated)
│ Mode: Simulate execution against target repository
│ Host Repo: YoheiFukuhara/gh-aw-trial
│ https://github.com/YoheiFukuhara/gh-aw-trial
│ Cleanup: Host repository will be preserved
════════════════════════════════════════════════════════════════════════════════
Execution Steps
════════════════════════════════════════════════════════════════════════════════
i 1. Create a private host repository
i 2. Install and compile my-workflow
i 3. Execute my-workflow
i 4. Preserve the host repository for inspection
i ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ Created host repository: https://github.com/YoheiFukuhara/gh-aw-trial
i
i IMPORTANT: You must enable GitHub Actions permissions for the repository.
i 1. Go to: https://github.com/YoheiFukuhara/gh-aw-trial/settings/actions
i 2. Under 'Workflow permissions', select 'Allow GitHub Actions to create and approve pull requests'
i 3. Click 'Save'
i
? Press Enter after you have enabled these permissions...
✓ Continuing with trial setup
i === Running trial for workflow: my-workflow ===
✗ failed to install workflow 'my-workflow' in trial mode
failed to fetch workflow
local workflow './my-workflow.md' not found
open ./my-workflow.md
no such file or directory
5. 本番実行
以下コマンドで本番実行。
$ gh aw run my-workflow
i Running 1 workflow(s)...
i https://github.com/YoheiFukuhara/ghaw-test/actions/runs/31580120047
✓ Successfully triggered workflow: my-workflow.lock.yml
i 🔗 View workflow run: https://github.com/YoheiFukuhara/ghaw-test/actions/runs/31580120047
i 💡 To analyze this run, use: gh aw audit 31580120047
✓ Successfully triggered 1 workflow(s)
6. 結果確認
gh aw logsでの確認
$ gh aw logs my-workflow
✓ Downloaded artifacts for run 31580120047
[summary] runs=1 duration=3.8m turns=0 errors=0 aic=14.2 tokens=5416 github_api=5 engines=copilot:1
[runs]
RUNID WORKFLOW ENGINE STATUS DUR TOKENS AIC TURNS ERR EVENT ACTOR BRANCH
31580120047 my-workflow copilot success 3.8m 5416 14.2 0 0 workflow_dispatch YoheiFukuhara main
[location] /home/fukuhara/repositories/investigation/ghaw-test/.github/aw/logs
[hint] Only the usage artifact was downloaded. Use --artifacts all to download all artifacts, or a specific set such as --artifacts agent, or combinations such as --artifacts agent,firewall. use --json for full details, -v for verbose, --format console for tables
gh aw audit での確認。
$ gh aw audit 31580120047
✅ my-workflow | success | 3.8m | https://github.com/YoheiFukuhara/ghaw-test/actions/runs/31580120047
run=31580120047 branch=main event=workflow_dispatch engine=copilot/auto/v1.0.78
fingerprint: directed/narrow/read_only/lean/standalone
metrics: errors=0 warnings=0 tokens=5.42k aic=14.16 action_min=4
session: wall=3.8m tok/min=1419
tokens: in=3.94k out=1.48k cache_read=113k reqs=1 steering=0
github_api: calls=5 quota=9/5.00k
jobs: 5/5 passed [activation:14.0s agent:1.6m detection:1.1m safe_outputs:10.0s conclusion:14.0s]
prompt: 9.56k chars file=aw-prompts/prompt.txt
logs: /home/fukuhara/repositories/investigation/ghaw-test/.github/aw/logs/run-31580120047
✓ Audit complete. Logs saved to /home/fukuhara/repositories/investigation/ghaw-test/.github/aw/logs/run-31580120047
i Tip: use --artifacts to select specific artifact sets (agent, firewall, mcp, activation, detection, etc.)

