Skip to content

Another Copilot CLI issue #20

Another Copilot CLI issue

Another Copilot CLI issue #20

Workflow file for this run

name: 🤖 GitHub Copilot Coder
on:
issues:
types: [labeled]
jobs:
copilot-cli:
# Only run when the issue has the 'copilot' label
if: contains(github.event.issue.labels.*.name, 'copilot')
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
env:
MODEL: claude-haiku-4.5
COPILOT_VERSION: 0.0.352
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_ASSIGNEE: ${{ github.event.issue.assignee.login }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
REPO_NAME: ${{ github.repository }}
BRANCH_NAME: copilot/${{ github.event.issue.number }}
steps:
- name: 🚀 Start Workflow
run: |
echo "🚀 GitHub Copilot Coder workflow started!"
echo "═══════════════════════════════════════════════════════════"
echo "📋 Issue: #${ISSUE_NUMBER}"
echo "📌 Title: ${ISSUE_TITLE}"
echo "👤 Creator: ${ISSUE_CREATOR}"
echo "📦 Repository: ${REPO_NAME}"
echo "🌿 Branch: ${BRANCH_NAME}"
echo "═══════════════════════════════════════════════════════════"
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
REPO_NAME: ${{ github.repository }}
BRANCH_NAME: copilot/${{ github.event.issue.number }}
- name: 📥 Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: 🏷️ Update Issue Labels - In Progress
run: |
gh issue edit ${{ env.ISSUE_NUMBER }} \
--add-label "in-progress" \
--remove-label "copilot"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: 🐍 Setup Python (Latest)
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: 📦 Install uv/uvx
run: |
echo "Installing uvx (pipx runner)..."
pip install --upgrade pip
pip install uv
echo "✅ Python and uv installed"
python --version
uv --version
- name: ⚙️ Setup Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: 🔍 Detect NPM Global Path
id: npm-path
run: |
NPM_PREFIX=$(npm config get prefix)
echo "NPM_GLOBAL_PATH=${NPM_PREFIX}/lib/node_modules" >> $GITHUB_ENV
echo "NPM global path: ${NPM_PREFIX}/lib/node_modules"
- name: 📦 Cache Global NPM Packages
uses: actions/cache@v4
with:
key: npm-global-${{ runner.os }}-copilot-${{ env.COPILOT_VERSION }}
path: ${{ env.NPM_GLOBAL_PATH }}
restore-keys: |
npm-global-${{ runner.os }}-copilot-
- name: 📦 Install Copilot CLI
run: |
if ! command -v copilot &> /dev/null; then
echo "Installing @github/copilot@${{ env.COPILOT_VERSION }}..."
npm install -g @github/copilot@${{ env.COPILOT_VERSION }}
else
echo "✅ @github/copilot already installed (from cache)"
copilot --version
fi
- name: ⚙️ Configure MCP Servers
run: |
mkdir -p ~/.config
cp mcp-config.json ~/.config/mcp-config.json
echo "✅ MCP configuration copied to ~/.config/mcp-config.json"
cat ~/.config/mcp-config.json
- name: 🧰 Check MCP Access
run: |
echo "🧰 Verifying MCP server access..."
copilot -p "List tools defined in the current chat session (do not run commands, I am asking about tools defined in the LLM). Just the names in a table, nothing else." --allow-all-tools
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
- name: 🌿 Create Feature Branch
run: |
echo "🌿 Creating feature branch..."
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b ${{ env.BRANCH_NAME }}
echo "✅ Branch ${{ env.BRANCH_NAME }} created"
- name: 🤖 Implement Changes with Copilot
run: |
echo "🤖 Running GitHub Copilot CLI..."
echo "═══════════════════════════════════════════════════════════"
echo "📋 Issue: #${ISSUE_NUMBER}"
echo "📌 Title: ${ISSUE_TITLE}"
echo "═══════════════════════════════════════════════════════════"
echo "This is the description that Copilot CLI is going to use to implement the task:"
echo "${ISSUE_BODY}"
mkdir -p logs
# Save issue body to file to avoid injection
printf '%s' "${ISSUE_BODY}" > /tmp/issue_description.txt
# Run Copilot with file input
copilot -p "Implement the GitHub issue following the description details: $(cat /tmp/issue_description.txt)" \
--allow-all-tools \
--log-level all \
--log-dir logs \
--model "${MODEL}"
# Clean up
rm -f /tmp/issue_description.txt
echo "✅ Implementation completed"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
MODEL: ${{ env.MODEL }}
- name: 💾 Commit Changes
run: |
./scripts/prepare-commit.sh "${ISSUE_NUMBER}" "${ISSUE_TITLE}" "${ISSUE_CREATOR}"
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
- name: 🚀 Push Branch
run: |
./scripts/push-branch.sh "${{ env.BRANCH_NAME }}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: 📬 Create Pull Request
id: create-pr
run: |
# Check if copilot-summary.md exists
if [ -f "copilot-summary.md" ]; then
PR_BODY=$(cat copilot-summary.md)
else
PR_BODY="## 🤖 Automated Implementation
This PR was automatically generated by GitHub Copilot CLI.
### 📋 Related Issue
Closes #${ISSUE_NUMBER}
### 📝 Changes
Please review the changes made by Copilot CLI."
fi
# Save PR body to file to avoid injection
printf '%s' "${PR_BODY}" > /tmp/pr_body.txt
# Create PR and capture URL - use file for body
PR_URL=$(gh pr create \
--title "${ISSUE_TITLE}" \
--body-file /tmp/pr_body.txt \
--base main \
--head "${BRANCH_NAME}" \
--label "copilot-generated" \
--assignee "${ISSUE_CREATOR}")
# Clean up
rm -f /tmp/pr_body.txt
echo "PR_URL=${PR_URL}" >> $GITHUB_ENV
echo "✅ Pull Request created: ${PR_URL}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
- name: 💬 Add Completion Comment to Issue
run: |
./scripts/post-workflow-comment.sh "${ISSUE_NUMBER}" "${PR_URL}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
PR_URL: ${{ env.PR_URL }}
- name: 🏷️ Update Issue Labels - Completed
run: |
gh issue edit ${{ env.ISSUE_NUMBER }} \
--add-label "completed,ready-for-review" \
--remove-label "in-progress"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: 📦 Publish Logs
uses: actions/upload-artifact@v4
if: always()
with:
name: copilot-logs
path: logs/
retention-days: 30