Skip to content

Commit 9a66d33

Browse files
committed
Merge branch 'raykao/act-2'
2 parents af90ea9 + e3ed31a commit 9a66d33

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Analyze Commit and Create Documentation Issue
2+
3+
Analyze commit `{COMMIT_SHA}` in repository `{REPOSITORY}` using the GitHub MCP server.
4+
5+
## Your Task
6+
7+
1. **Examine the commit** using MCP to access:
8+
- Commit diff and changed files
9+
- Current documentation structure
10+
- Project context
11+
12+
2. **Decide if documentation is needed** based on these criteria:
13+
14+
### ✅ Document These:
15+
- Public APIs/Interfaces (functions, classes, endpoints)
16+
- Complex logic requiring explanation
17+
- Architectural or workflow changes
18+
- Breaking changes
19+
- New dependencies or integrations
20+
- Security/performance changes
21+
- Database schemas or data models
22+
- Unit tests
23+
24+
### ❌ Skip These:
25+
- Minor refactoring or formatting
26+
- Internal helpers
27+
- Trivial typo fixes
28+
- Code moves without logic changes
29+
- Patch dependency updates
30+
in the current repository
31+
- Add labels: `documentation`, `automated`
32+
3. **If documentation is needed:**
33+
- Use the GitHub MCP server to create a GitHub issue with title: "📚 Documentation needed for commit test"
34+
- Use assign_copilot_to_issue tool to assign @copilot to issue.
35+
- In the issue body, explain:
36+
- What changed and why it needs documentation
37+
- Which documentation files should be updated
38+
- Any breaking changes or migration notes needed
39+
- Confirm if all steps succeeded or not.
40+
41+
4. **If documentation is NOT needed:**
42+
- Simply explain why in a brief response (no issue needed)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Generate Documentation with Copilot
2+
3+
# Modified from @sitoader's workflow at: https://github.com/sitoader/AgenticWorkflows/blob/main/.github/workflows/generate-docs.yml
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths-ignore:
9+
- 'docs/**'
10+
- '**.md'
11+
12+
jobs:
13+
generate-docs:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read # Required to read repository content and commit diffs
17+
issues: write # Required to create GitHub issues for documentation recommendations
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Install GitHub Copilot CLI
26+
run: |
27+
curl -fsSL https://gh.io/copilot-install | bash
28+
echo "Installed Copilot CLI version:"
29+
copilot --version
30+
31+
- name: Analyze and delegate to Copilot
32+
env:
33+
GITHUB_MCP_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Workflow token for MCP GitHub operations (issues)
34+
GITHUB_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }} # Personal PAT for Copilot API authentication
35+
run: |
36+
echo "Analyzing commit ${{ github.sha }}"
37+
echo "Loading documentation criteria from prompt..."
38+
39+
PROMPT=$(cat .github/prompts/analyze-for-docs.prompt.md)
40+
PROMPT="${PROMPT//\{COMMIT_SHA\}/${{ github.sha }}}"
41+
PROMPT="${PROMPT//\{REPOSITORY\}/${{ github.repository }}}"
42+
43+
echo "Delegating to GitHub Copilot..."
44+
echo "- Copilot will use MCP to examine the commit"
45+
echo "- Copilot will decide if documentation is needed"
46+
echo "- Copilot will create an issue and assign it to itself if needed"
47+
echo ""
48+
49+
copilot -p "$PROMPT" \
50+
--allow-all-tools
51+
52+
# Todo: Add the step to commit generated docs back to the repo if desired

Act-2/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Act-2: Standards Exist, but They’re Not Enforced
2+
3+
Problem:
4+
You are part of a team that is busy doing the things you love: create solutions to problems (e.g. write code), but you do not consistently do the things you dislike (e.g. write documentation). No blame, no shame...you're only human.
5+
6+
Answer:
7+
Let the non-human do the things you dislike.
8+
9+
## Crawl
10+
11+
Create a reusable prompt (or agent) for the team to run arbitrarily when you have new code or new things to document. In GitHub Copilot in VSCode you can call a reusable prompt via "Slash Commands" if you follow the folder/naming convension set out by GitHub/VScode (i.e. `<repo-root>/.github/prompts/<prompt-name>.prompt.md`).
12+
13+
Execute this prompt locally:
14+
15+
![write-prompt](images/write-prompt.png)
16+
17+
## Walk/Run
18+
19+
Create a GitHub Action Workflow that will be called upon for each push to the repo. For this example it will be just for the main branch, but you can set up the triggers/rules for when the workflow gets run. See the docs about [Events That Trigger Workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows).
20+
21+
> [!NOTE]
22+
> We will use the GitHub Copilot CLI to automate the execution of our custom prompt in a scripted CI Runner - GitHub Actions.
23+
24+
We have an example of this in [Act-2 .github/workflows](../.github/workflows/copilot.generate-docs.yml).
25+
26+
### What does this do?
27+
28+
- The GitHub Action Workflow triggers on each push to the main branch - this ensures that documentation is created, if and when needed regardless if you remembered or not. This ensures that all team members have docs created for them, even if they did not run the `/write-docs` prompt manually before committing their changes. It also can be run manually in GitHub Actions since it also has the `workflow_dispatch` trigger enabled...this is optional of course but we have it here as an example anyways.
29+
- It installs the GitHub Copilot CLI
30+
- It ensures that we provide it credentials to call GitHub Copilot
31+
> [!NOTE]
32+
> Currently calling GitHub Copilot is a User only ability - meaning that GitHub Copilot is licensed to and therefore only callable by a human user account. In this example we have stored a Fine-Grained GitHub Personal Access Token (PAT -> a user bound API Key) that has been scoped with the `Copilot-Requests: Read-only` Permission. As such this will consume GitHub Copilot PRUs (Premium Request Units) from the tied user account. Today this is the only billing model to consume GitHub Copilot.
33+
- Store the required prompt file contents as an environment variable
34+
- Pass in the prompt and call GitHub Copilot CLI to generate docs

Act-2/images/write-prompt.png

5.69 KB
Loading

0 commit comments

Comments
 (0)