Repository navigation
Conversation
Adds a gh-aw agentic workflow triggered by /preflight comment on PRs. Gathers context from linked issues, review comments, and changed files, then posts a structured summary comment with expandable sections. - Trigger: /preflight comment or workflow_dispatch - Model: claude-sonnet-4 - Security: fork PR guard, read-only permissions, safe-outputs - Output: 🤖 AI Pre-flight comment with issue summary, file classification, review comments, edge cases, and fix approach sections Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34607Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34607" |
There was a problem hiding this comment.
Pull request overview
Adds a new gh-aw “agentic workflow” that can be triggered via /preflight to gather PR context (metadata, linked issues, discussion, changed files) and post a structured “AI Pre-flight” summary comment back onto the PR.
Changes:
- Introduces a new
/preflight-triggered agent workflow definition in gh-aw Markdown format. - Adds the compiled gh-aw workflow lock file used by GitHub Actions execution.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/workflows/pr-preflight.md |
Defines the gh-aw prompt + frontmatter for the PR pre-flight workflow, including a custom PR checkout guard and the required output comment format. |
.github/workflows/pr-preflight.lock.yml |
Compiled GitHub Actions workflow that runs the agent (Copilot CLI) and posts safe-output comments back to the PR. |
| - name: Configure gh CLI for GitHub Enterprise | ||
| run: bash ${RUNNER_TEMP}/gh-aw/actions/configure_gh_for_ghe.sh | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| - env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ github.event.issue.number || inputs.pr_number }} | ||
| name: Checkout PR branch | ||
| run: "if [ -n \"$PR_NUMBER\" ] && [ \"$PR_NUMBER\" != \"0\" ]; then\n echo \"Checking out PR #$PR_NUMBER...\"\n\n # Guard: block fork PRs to prevent fork code execution\n HEAD_OWNER=$(gh pr view \"$PR_NUMBER\" --repo \"$GITHUB_REPOSITORY\" --json headRepositoryOwner --jq '.headRepositoryOwner.login' 2>/dev/null || echo \"\")\n BASE_OWNER=$(echo \"$GITHUB_REPOSITORY\" | cut -d'/' -f1)\n if [ -n \"$HEAD_OWNER\" ] && [ \"$HEAD_OWNER\" != \"$BASE_OWNER\" ]; then\n echo \"⚠️ PR #$PR_NUMBER is from fork ($HEAD_OWNER). Skipping checkout for security.\"\n echo \"The agent will use GitHub API to read PR data instead.\"\n exit 0\n fi\n\n gh pr checkout \"$PR_NUMBER\" --repo \"$GITHUB_REPOSITORY\"\n echo \"✅ Checked out PR #$PR_NUMBER\"\n git log --oneline -1\nelse\n echo \"No PR number available, using default checkout\"\nfi" | ||
|
|
||
| - name: Configure Git credentials | ||
| env: | ||
| REPO_NAME: ${{ github.repository }} | ||
| SERVER_URL: ${{ github.server_url }} | ||
| run: | | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global am.keepcr true | ||
| # Re-authenticate git with GitHub token | ||
| SERVER_URL_STRIPPED="${SERVER_URL#https://}" | ||
| git remote set-url origin "https://x-access-token:${{ github.token }}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git" | ||
| echo "Git configured with standard GitHub Actions identity" | ||
| - name: Checkout PR branch | ||
| id: checkout-pr | ||
| if: | | ||
| github.event.pull_request || github.event.issue.pull_request | ||
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} | ||
| with: | ||
| github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); | ||
| setupGlobals(core, github, context, exec, io); | ||
| const { main } = require('${{ runner.temp }}/gh-aw/actions/checkout_pr_branch.cjs'); | ||
| await main(); | ||
| - name: Install GitHub Copilot CLI |
There was a problem hiding this comment.
The fork-PR checkout guard in the shell step is ineffective because the workflow performs a second PR checkout via checkout_pr_branch.cjs afterwards. That later checkout is unconditional for PR issue_comment events and can still fetch/checkout fork code, defeating the stated security model. Consider removing one of the checkout steps, or ensure the checkout_pr_branch.cjs step is explicitly skipped for fork PRs (fail-closed) so no fork code is ever checked out/executed.
| # Guard: block fork PRs to prevent fork code execution | ||
| HEAD_OWNER=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json headRepositoryOwner --jq '.headRepositoryOwner.login' 2>/dev/null || echo "") | ||
| BASE_OWNER=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) | ||
| if [ -n "$HEAD_OWNER" ] && [ "$HEAD_OWNER" != "$BASE_OWNER" ]; then | ||
| echo "⚠️ PR #$PR_NUMBER is from fork ($HEAD_OWNER). Skipping checkout for security." | ||
| echo "The agent will use GitHub API to read PR data instead." | ||
| exit 0 | ||
| fi | ||
|
|
||
| gh pr checkout "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" |
There was a problem hiding this comment.
The fork-PR guard is fail-open: if gh pr view fails, HEAD_OWNER becomes empty and the script proceeds to gh pr checkout, which could execute untrusted fork code. This should fail closed (treat unknown head owner as fork/unsafe and skip checkout) and ideally set an explicit flag the rest of the workflow/prompt can use.
| - **Repository**: ${{ github.repository }} | ||
| - **PR Number**: ${{ github.event.issue.number || inputs.pr_number }} | ||
|
|
||
| The PR branch has been checked out for you. All files from the PR are available locally. |
There was a problem hiding this comment.
The prompt states the PR branch has been checked out and that all PR files are available locally, but the workflow explicitly skips checkout for fork PRs. This makes the instructions misleading and can cause the agent to incorrectly rely on local files that are actually from the default branch. Update the text to reflect that checkout may be skipped (and that API-only context is used in that case).
| The PR branch has been checked out for you. All files from the PR are available locally. | |
| In some cases (non-fork PRs), the PR branch is checked out and files are available locally. For fork PRs, checkout may be skipped — in that case, rely **only** on GitHub API/MCP tools for PR context and do not assume local files match the PR. |
| permissions: | ||
| contents: read | ||
| discussions: write | ||
| issues: write | ||
| pull-requests: write | ||
| timeout-minutes: 15 |
There was a problem hiding this comment.
The PR description claims the workflow runs with read-only permissions, but the compiled workflow necessarily requests write permissions (e.g., issues: write, pull-requests: write) in the safe_outputs/conclusion jobs to post comments and failure reports. Please align the PR description/security model documentation with the actual permissions requested by the workflow.
Enables GitHub to discover the workflow from PR branches so workflow_dispatch can be used for testing before merging to main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The GitHub MCP server's integrity policy blocks agent reads of PR data. Move all data fetching to pre-agent steps (which run outside the firewall with GH_TOKEN) and write to /tmp/gh-aw/preflight-context/ for the agent to read as local files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
Adds a GitHub Actions agentic workflow that performs AI-powered pre-flight analysis on PRs, triggered by commenting
/preflight.What it does
When someone comments
/preflighton a PR, this workflow:🤖 AI Pre-flightwith expandable<details>sectionsComment sections
Security model
Follows the same patterns as PR #34548 (copilot-evaluate-tests):
COPILOT_GITHUB_TOKENfor Copilot API;github.tokenfor PR operationscontents: read,issues: read,pull-requests: readTriggers
/preflightcomment on any PRworkflow_dispatchwith PR number input (for manual testing)Files added
.github/workflows/pr-preflight.md— gh-aw workflow source.github/workflows/pr-preflight.lock.yml— compiled workflow (auto-generated bygh aw compile)Prerequisites
Requires the
COPILOT_GITHUB_TOKENrepo secret (same one used by CI Doctor and evaluate-tests workflows).