-
Notifications
You must be signed in to change notification settings - Fork 66.9k
119 lines (106 loc) · 4.67 KB
/
copilot-setup-steps.yml
File metadata and controls
119 lines (106 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: 'Copilot Environment Setup'
# **What it does**: Sets up the environment for Copilot coding agent to test content and script changes.
# **Why we have it**: Ensures Copilot can validate content with linters and formatters before making changes.
# **Who does it impact**: Copilot coding agent and developers using repository custom instructions.
on:
workflow_dispatch:
inputs:
check_content:
description: 'Check content files with content linter'
required: false
default: true
type: boolean
check_scripts:
description: 'Check TypeScript/JavaScript/SCSS files with prettier and linter'
required: false
default: true
type: boolean
paths:
description: 'Specific file paths to check (space-separated), or leave empty for changed files'
required: false
type: string
permissions:
contents: read
jobs:
copilot-setup-steps:
if: github.repository == 'github/docs-internal'
runs-on: ${{ github.repository == 'github/docs-internal' && 'ubuntu-20.04-xl' || 'ubuntu-latest' }}
steps:
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Node and dependencies
uses: ./.github/actions/node-npm-setup
- name: Get changed files if no specific paths provided
if: inputs.paths == ''
id: changed_files
uses: ./.github/actions/get-changed-files
with:
files: |
content/**
data/**
src/**/*.{ts,tsx,js,mjs}
**/*.scss
- name: Set file paths for checking
id: set_paths
run: |
if [ -n "${{ inputs.paths }}" ]; then
echo "files_to_check=${{ inputs.paths }}" >> $GITHUB_OUTPUT
else
echo "files_to_check=${{ steps.changed_files.outputs.filtered_changed_files }}" >> $GITHUB_OUTPUT
fi
- name: Run content linter on content/data files
if: inputs.check_content == true && (contains(steps.set_paths.outputs.files_to_check, 'content/') || contains(steps.set_paths.outputs.files_to_check, 'data/'))
env:
FILES_TO_CHECK: ${{ steps.set_paths.outputs.files_to_check }}
run: |
# Filter for content and data files only
CONTENT_FILES=$(echo "$FILES_TO_CHECK" | tr ' ' '\n' | grep -E '^(content|data)/' | tr '\n' ' ' || true)
if [ -n "$CONTENT_FILES" ]; then
echo "Running content linter on: $CONTENT_FILES"
npm run lint-content -- --paths $CONTENT_FILES
else
echo "No content or data files to check"
fi
- name: Run prettier check on script files
if: inputs.check_scripts == true
env:
FILES_TO_CHECK: ${{ steps.set_paths.outputs.files_to_check }}
run: |
# Filter for TypeScript, JavaScript, and SCSS files
SCRIPT_FILES=$(echo "$FILES_TO_CHECK" | tr ' ' '\n' | grep -E '\.(ts|tsx|js|mjs|scss)$' | tr '\n' ' ' || true)
if [ -n "$SCRIPT_FILES" ]; then
echo "Running prettier check on: $SCRIPT_FILES"
npm run prettier-check -- $SCRIPT_FILES
else
echo "No script files to check with prettier"
fi
- name: Run ESLint on script files
if: inputs.check_scripts == true
env:
FILES_TO_CHECK: ${{ steps.set_paths.outputs.files_to_check }}
run: |
# Filter for TypeScript and JavaScript files only (ESLint doesn't handle SCSS)
SCRIPT_FILES=$(echo "$FILES_TO_CHECK" | tr ' ' '\n' | grep -E '\.(ts|tsx|js|mjs)$' | tr '\n' ' ' || true)
if [ -n "$SCRIPT_FILES" ]; then
echo "Running ESLint on: $SCRIPT_FILES"
npx eslint $SCRIPT_FILES
else
echo "No JavaScript/TypeScript files to lint"
fi
- name: Run TypeScript compiler check
if: inputs.check_scripts == true && (contains(steps.set_paths.outputs.files_to_check, '.ts') || contains(steps.set_paths.outputs.files_to_check, '.tsx'))
run: |
echo "Running TypeScript compiler check"
npm run tsc
- name: Environment setup summary
run: |
echo "✅ Copilot environment setup completed successfully!"
echo ""
echo "Available commands for content validation:"
echo "- Content linting: npm run lint-content -- --paths <file-paths>"
echo "- Prettier formatting: npm run prettier-check -- <file-paths>"
echo "- ESLint: npm run lint"
echo "- TypeScript check: npm run tsc"
echo "- All tests: npm test"
echo ""
echo "For more guidance, see .github/copilot-instructions.md"