|
9 | 9 | branches: [ main ] |
10 | 10 | paths: |
11 | 11 | - '.github/workflows/**' |
12 | | - - '**/*.js' |
13 | | - - '**/*.ts' |
14 | | - - '**/*.mjs' |
15 | | - - '**/*.cjs' |
16 | | - - 'package.json' |
17 | | - - 'pnpm-lock.yaml' |
| 12 | + - '.github/actions/**' |
18 | 13 | - '.github/workflows/codeql.yml' |
19 | 14 | pull_request: |
20 | 15 | branches: [ main ] |
21 | 16 | paths: |
22 | 17 | - '.github/workflows/**' |
23 | | - - '**/*.js' |
24 | | - - '**/*.ts' |
25 | | - - '**/*.mjs' |
26 | | - - '**/*.cjs' |
27 | | - - 'package.json' |
28 | | - - 'pnpm-lock.yaml' |
| 18 | + - '.github/actions/**' |
29 | 19 | - '.github/workflows/codeql.yml' |
30 | 20 | schedule: |
31 | 21 | # Run weekly on Mondays at 2 AM UTC |
32 | 22 | - cron: '0 2 * * 1' |
33 | 23 |
|
| 24 | +permissions: |
| 25 | + contents: read |
| 26 | + |
34 | 27 | jobs: |
35 | 28 | analyze: |
36 | 29 | name: Analyze (${{ matrix.language }}) |
37 | 30 | runs-on: ubuntu-latest |
38 | 31 | permissions: |
39 | 32 | actions: read |
40 | 33 | contents: read |
41 | | - issues: write |
42 | 34 | security-events: write |
43 | | - pull-requests: write |
44 | 35 |
|
45 | 36 | strategy: |
46 | 37 | fail-fast: false |
47 | 38 | matrix: |
48 | | - language: [ 'actions' ] |
| 39 | + include: |
| 40 | + - language: actions |
| 41 | + build-mode: none |
49 | 42 |
|
50 | 43 | steps: |
51 | | - - name: Checkout repository |
52 | | - uses: actions/checkout@v7 |
53 | | - |
54 | | - - name: Initialize CodeQL |
55 | | - uses: github/codeql-action/init@v4 |
56 | | - with: |
57 | | - languages: ${{ matrix.language }} |
58 | | - queries: security-extended,security-and-quality |
59 | | - |
60 | | - - name: Perform CodeQL Analysis |
61 | | - id: analyze |
62 | | - uses: github/codeql-action/analyze@v4 |
63 | | - with: |
64 | | - category: "/language:${{matrix.language}}" |
65 | | - upload: true |
66 | | - |
67 | | - - name: Comment PR with CodeQL Results |
68 | | - if: github.event_name == 'pull_request' && steps.analyze.outcome == 'success' |
69 | | - uses: actions/github-script@v9 |
70 | | - with: |
71 | | - script: | |
72 | | - const body = `🔍 **CodeQL Analysis Complete** (${{ matrix.language }}) |
73 | | - |
74 | | - CodeQL analysis has completed successfully. Results are available in the **Security** tab of this PR. |
75 | | - |
76 | | - **Language Analyzed:** ${{ matrix.language }} |
77 | | - **Query Suite:** security-extended, security-and-quality |
78 | | - |
79 | | - 📋 **View Results:** |
80 | | - - Check the Security tab above for detailed findings |
81 | | - - Review any alerts and address them before merging |
82 | | - |
83 | | - > **Note:** CodeQL does not natively support PowerShell. This analysis covers GitHub Actions workflows in \`.github/workflows\`. |
84 | | - |
85 | | - *Analysis performed automatically by CodeQL*`; |
86 | | - |
87 | | - github.rest.issues.createComment({ |
88 | | - issue_number: context.issue.number, |
89 | | - owner: context.repo.owner, |
90 | | - repo: context.repo.repo, |
91 | | - body: body |
92 | | - }); |
93 | | -
|
94 | | - - name: Comment PR with CodeQL Errors |
95 | | - if: github.event_name == 'pull_request' && steps.analyze.outcome == 'failure' |
96 | | - uses: actions/github-script@v9 |
97 | | - with: |
98 | | - script: | |
99 | | - const body = `❌ **CodeQL Analysis Failed** (${{ matrix.language }}) |
100 | | - |
101 | | - CodeQL analysis encountered an error. Please check the workflow logs for details. |
102 | | - |
103 | | - **Language:** ${{ matrix.language }} |
104 | | - |
105 | | - *Check the workflow run for error details.*`; |
106 | | - |
107 | | - github.rest.issues.createComment({ |
108 | | - issue_number: context.issue.number, |
109 | | - owner: context.repo.owner, |
110 | | - repo: context.repo.repo, |
111 | | - body: body |
112 | | - }); |
| 44 | + - name: Checkout repository |
| 45 | + uses: actions/checkout@v7 |
| 46 | + |
| 47 | + - name: Initialize CodeQL |
| 48 | + uses: github/codeql-action/init@v4 |
| 49 | + with: |
| 50 | + languages: ${{ matrix.language }} |
| 51 | + build-mode: ${{ matrix.build-mode }} |
| 52 | + # security-and-quality includes security-extended for Actions workflows |
| 53 | + queries: security-and-quality |
| 54 | + |
| 55 | + - name: Perform CodeQL Analysis |
| 56 | + uses: github/codeql-action/analyze@v4 |
| 57 | + with: |
| 58 | + category: "/language:${{ matrix.language }}" |
0 commit comments