-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub Actions workflow for automated Copilot setup steps #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joe10832
merged 5 commits into
main
from
copilot/fix-5d7b168e-c5c7-4503-b6d7-034d949ebfe6
Sep 29, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7273129
Initial plan
Copilot 50fbcb1
Add GitHub Actions workflow for Copilot setup steps
Copilot 29e48aa
Update .github/workflows/copilot-setup-steps.yml
joe10832 1e284f6
Update .github/workflows/copilot-setup-steps.yml
joe10832 d9ed36a
Update .github/workflows/copilot-setup-steps.yml
joe10832 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| --- | ||
| name: GitHub Copilot Setup Steps | ||
|
|
||
| # This workflow sets up the environment for GitHub Copilot coding agents | ||
| # to work efficiently with the repository | ||
|
|
||
| on: | ||
| # Trigger on pushes to main branch for validation | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - '.github/**' | ||
| - '**.md' | ||
| - 'package*.json' | ||
|
|
||
| # Trigger on pull requests for validation | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - '.github/**' | ||
| - '**.md' | ||
| - 'package*.json' | ||
|
|
||
| # Allow manual execution of the workflow | ||
| workflow_dispatch: | ||
| inputs: | ||
| setup_type: | ||
| description: 'Type of setup to run' | ||
| required: false | ||
| default: 'full' | ||
| type: choice | ||
| options: | ||
| - full | ||
| - validation-only | ||
| - dependencies-only | ||
|
|
||
| # Security: Use minimal permissions following GitHub Actions best practices | ||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| setup: | ||
| name: Copilot Environment Setup | ||
| runs-on: ubuntu-latest | ||
|
|
||
| # Security: Don't run on forks to prevent resource abuse | ||
| if: > | ||
| github.repository == github.event.repository.full_name | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # Fetch minimal history for security | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Setup Node.js 20 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| # Enable caching for faster subsequent runs | ||
| cache: 'npm' | ||
| # Use package-lock.json if exists for consistent dependencies | ||
| cache-dependency-path: | | ||
| package-lock.json | ||
| **/package-lock.json | ||
|
|
||
| - name: Verify Node.js installation | ||
| run: | | ||
| echo "Node.js version: $(node --version)" | ||
| echo "npm version: $(npm --version)" | ||
| echo "Environment setup complete for GitHub Copilot agents" | ||
|
|
||
| - name: Check for package.json | ||
| id: check-package | ||
| run: | | ||
| if [ -f "package.json" ]; then | ||
| echo "package-exists=true" >> $GITHUB_OUTPUT | ||
| echo "Found package.json - will install dependencies" | ||
| else | ||
| echo "package-exists=false" >> $GITHUB_OUTPUT | ||
| echo "No package.json found - skipping dependency installation" | ||
| fi | ||
|
|
||
| - name: Install dependencies | ||
| if: > | ||
| steps.check-package.outputs.package-exists == 'true' && | ||
| (github.event.inputs.setup_type != 'validation-only') | ||
| run: | | ||
| echo "Installing Node.js dependencies..." | ||
| npm ci --prefer-offline --no-audit | ||
| env: | ||
| # Security: Disable npm audit automatically for CI | ||
| NODE_ENV: production | ||
|
|
||
| - name: Validate repository structure | ||
| run: | | ||
| echo "Validating repository structure for GitHub Copilot agents..." | ||
|
|
||
| # Check for essential Copilot instruction files | ||
| echo "Checking for Copilot instruction files:" | ||
|
|
||
| if [ -f ".github/copilot-instructions.md" ]; then | ||
| echo "✅ .github/copilot-instructions.md found" | ||
| else | ||
| echo "⚠️ .github/copilot-instructions.md missing" | ||
| fi | ||
|
|
||
| if [ -d ".github/instructions" ]; then | ||
| echo "✅ .github/instructions directory found" | ||
| echo "Available instruction files:" | ||
| ls -la .github/instructions/ | ||
| else | ||
| echo "⚠️ .github/instructions directory not found" | ||
| fi | ||
|
|
||
| # Check for agent-specific instruction files | ||
| echo "Checking for agent instruction files:" | ||
| for file in AGENTS.md CLAUDE.md GEMINI.md; do | ||
| if [ -f "$file" ]; then | ||
| echo "✅ $file found" | ||
| else | ||
| echo "⚠️ $file not found" | ||
| fi | ||
| done | ||
|
|
||
| - name: Validate instruction file syntax | ||
| run: | | ||
| echo "Validating Markdown syntax in instruction files..." | ||
|
|
||
| # Check if markdownlint is available or install it | ||
| if ! command -v markdownlint &> /dev/null; then | ||
| echo "Installing markdownlint for validation..." | ||
| npm install -g markdownlint-cli | ||
| fi | ||
|
|
||
| # Validate key instruction files | ||
| if [ -f ".github/copilot-instructions.md" ]; then | ||
| echo "Validating .github/copilot-instructions.md..." | ||
| markdownlint .github/copilot-instructions.md || \ | ||
| echo "⚠️ Markdown validation warnings" | ||
| fi | ||
|
|
||
| # Validate other instruction files | ||
| for file in *.md; do | ||
| if [ -f "$file" ]; then | ||
| echo "Validating $file..." | ||
| markdownlint "$file" || \ | ||
| echo "⚠️ Markdown validation warnings in $file" | ||
| fi | ||
| done | ||
|
|
||
| - name: Generate setup summary | ||
| if: always() | ||
| run: | | ||
| echo "## GitHub Copilot Setup Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Node.js 20 | ✅ Installed" >> $GITHUB_STEP_SUMMARY | ||
| echo "| npm | ✅ Available" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| if [ -f "package.json" ]; then | ||
| echo "| Dependencies | ✅ Ready for installation" \ | ||
| >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "| Dependencies | ⚠️ No package.json found" \ | ||
| >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
| if [ -f ".github/copilot-instructions.md" ]; then | ||
| echo "| Copilot Instructions | ✅ Available" \ | ||
| >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "| Copilot Instructions | ❌ Missing" \ | ||
| >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "Environment ready for GitHub Copilot coding agents." \ | ||
| >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### For Copilot Agents:" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Node.js 20 environment is available" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Repository structure has been validated" \ | ||
| >> $GITHUB_STEP_SUMMARY | ||
| echo "- All instruction files are accessible" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Use \`npm ci\` to install dependencies if needed" \ | ||
| >> $GITHUB_STEP_SUMMARY | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing markdownlint-cli globally every time the command is not found is inefficient. Consider using
npx markdownlint-clito run it without global installation, or add it as a project dependency to leverage npm caching.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot-setup-steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/opt/hostedtoolcache/node/20.19.5/x64/bin/npm config get cache # Set the permissions to the lowest permissions possible needed for your steps.
Copilot will be given its own token for its operations.
permissions:
If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the
contents: readpermission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.contents: read
You can define any steps you want, and they will run before the agent starts.
If you do not check out your code, Copilot will do this for you.
steps:
name: Checkout code
uses: actions/checkout@v5
name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
name: Install JavaScript dependencies
run: npm ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
steps:
name: Checkout code
uses: actions/checkout@v5
name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
name: Install JavaScript dependencies
run: npm ci @copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/opt/hostedtoolcache/node/20.19.5/x64/bin/npm config get cache
/home/runner/.npm @Copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update .github/workflows/ copilot-setup-steps.yml @copilot