Project 7 — PR-Description Generator in GitHub Actions
Action that calls Copilot to draft a PR description.
What You Will Learn
- Build a GitHub Action.
- Call Copilot from CI.
- Generate PR descriptions.
- Wire into PR creation.
- Measure review time saved.
Why This Matters
PR descriptions take 5–15 minutes each. An Action that auto-generates them saves developers time and ensures consistency. This project delivers a real CI integration.
Concept Explained
A GitHub Action that triggers on PR open. Calls Copilot API (or uses Copilot CLI) to generate a description from the diff. Posts as a comment or sets the description.
How It Works
Create .github/workflows/pr-description.yml. Use Copilot CLI or API to generate description from git diff. Update PR body or post as comment.
Step-by-Step Tutorial
1. Create workflow
.github/workflows/pr-description.yml2. Trigger on PR open
on: pull_request: types: [opened]3. Get diff
git diff main...HEAD4. Generate description
Call Copilot with the diff. Use template: title, summary, test plan, risk.5. Post to PR
Update PR body or comment.Real-World Example
A team added a PR-description generator Action. Saved 5–10 minutes per PR. Across 30 PRs/week: 3–5 hours saved. Reviewers loved consistent format.
Example Prompts / Commands / Code
# .github/workflows/pr-description.yml
name: Generate PR Description
on:
pull_request:
types: [opened]
jobs:
generate-description:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get diff
id: diff
run: echo "diff=$(git diff origin/main...HEAD)" >> $GITHUB_OUTPUT
- name: Generate description
id: desc
run: |
DESCRIPTION=$(echo "${{ steps.diff.outputs.diff }}" | \
copilot 'Generate a PR description for this diff. \
Include: title, summary, test plan, risk notes. \
Format as markdown.' \
--no-interactive)
echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT
- name: Update PR
uses: actions/github-script@v6
with:
script: |
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
body: `${{ steps.desc.outputs.description }}`
});
Common Mistakes
- Generating without review — quality varies.
- Triggering on every PR edit — too noisy.
- Not using a template — descriptions inconsistent.
- Forgetting to redact secrets in diffs.
Best Practices
- Trigger on PR open only.
- Use a consistent template (title, summary, test plan, risk).
- Let author review and edit before finalizing.
- Redact secrets from diff before sending.
- Measure review time saved.
Troubleshooting
| Problem | How to Fix |
|---|---|
| Action fails | Check Copilot CLI is available in the runner. Or use the API. |
| Descriptions are generic | Improve the template. Add constraints. |
Practical Exercise
Your Turn
Build a PR-description generator Action for a sample repo. Trigger on PR open. Generate and post description.
Professional Challenge
Extend the Action to also suggest reviewers based on the diff (which files changed, who owns them).
Key Takeaways
- GitHub Action triggers on PR open.
- Generate description from git diff.
- Use consistent template.
- Let author review before finalizing.
- Measure review time saved.
Frequently Asked Questions
Does this replace author's description?
Cost?
Further Reading
Official References
SEO Metadata
SEO title: Project 7 — PR-Description Generator in GitHub Actions
Meta description: Action that calls Copilot to draft a PR description.
Primary keyword: project 7
Secondary keywords: project 7 — pr-description generator in github actions
Search intent: Informational
URL slug: /project-pr-description-generator-github-actions-copilot
Categories: AI Tools, GitHub Copilot
Tags: GitHub Copilot, Intermediate, Project, GitHub Actions, CI/CD, PR, IMCSEIAN, Tutorial, IMCSEIAN
Featured image concept: IMCSEIAN lesson card for Project 7 — PR-Description Generator in GitHub Actions
Comments
Comments
Post a Comment