Skip to content

Commit d528019

Browse files
committed
Refactor CodeQL workflow to enable analysis for JavaScript and exclude Python files, adding language detection overrides in .gitattributes
1 parent 7870785 commit d528019

2 files changed

Lines changed: 60 additions & 11 deletions

File tree

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Language detection overrides for GitHub
2+
3+
# Mark Markdown files as detectable (documentation)
4+
*.md linguist-detectable=true
5+
*.html linguist-detectable=true
6+
7+
# Exclude Python from language detection
8+
*.py linguist-generated=true
9+
*.py linguist-detectable=false
10+
11+
# Documentation repository
12+
docs/ linguist-documentation=false
13+
*.md linguist-documentation=false
Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,55 @@
1-
name: "Disable CodeQL Analysis"
1+
name: "CodeQL Analysis"
22

3-
# This workflow is intentionally disabled for this documentation repository
4-
# This file exists to prevent GitHub from automatically enabling CodeQL
3+
# This workflow explicitly excludes Python analysis for this documentation repository
54

65
on:
7-
# Don't run automatically - set to manual only
8-
workflow_dispatch:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
schedule:
11+
- cron: '0 0 * * 0' # Run once a week
912

1013
jobs:
11-
no-analysis:
12-
name: No CodeQL Analysis
14+
analyze:
15+
name: Analyze
1316
runs-on: ubuntu-latest
17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
# Override automatic language detection to explicitly exclude Python
26+
language: [ 'javascript' ] # Only include JavaScript if needed
27+
1428
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v4
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
1731

18-
- name: Skip Analysis
19-
run: echo "CodeQL Analysis intentionally disabled for this documentation repository"
32+
# Explicitly exclude Python files
33+
- name: Setup Python exclusion
34+
run: |
35+
echo "# Language detection overrides" > .gitattributes
36+
echo "*.py linguist-generated=true" >> .gitattributes
37+
echo "*.md linguist-detectable=true" >> .gitattributes
38+
echo "*.html linguist-detectable=true" >> .gitattributes
39+
git add .gitattributes
40+
git config --global user.name "GitHub Actions"
41+
git config --global user.email "actions@github.com"
42+
git commit -m "Add gitattributes to help language detection" || echo "No changes to commit"
43+
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
config-file: ./.github/codeql/codeql-config.yml
49+
# Skip Python extraction
50+
tools: '!python'
51+
52+
- name: Perform CodeQL Analysis
53+
uses: github/codeql-action/analyze@v2
54+
with:
55+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)