|
| 1 | +name: "CodeQL" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + schedule: |
| 9 | + - cron: '0 0 * * 0' |
| 10 | + |
| 11 | +jobs: |
| 12 | + analyze: |
| 13 | + name: Analyze (${{ matrix.language }}) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + # required for all workflows |
| 17 | + security-events: write |
| 18 | + # required to fetch internal or private CodeQL packs |
| 19 | + packages: read |
| 20 | + # only required for workflows in private repositories |
| 21 | + actions: read |
| 22 | + contents: read |
| 23 | + |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - language: javascript-typescript |
| 29 | + build-mode: none |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Clean up disk space |
| 33 | + run: | |
| 34 | + echo "Disk space before cleanup:" |
| 35 | + df -h |
| 36 | + echo "" |
| 37 | + echo "Cleaning up unnecessary files to free disk space..." |
| 38 | + |
| 39 | + # Remove large tool directories that aren't needed for JavaScript/TypeScript CodeQL analysis |
| 40 | + # These tools will be re-downloaded by GitHub Actions if needed for other jobs |
| 41 | + sudo rm -rf /usr/share/dotnet |
| 42 | + sudo rm -rf /opt/ghc |
| 43 | + sudo rm -rf /usr/local/share/boost |
| 44 | + sudo rm -rf /usr/local/lib/android |
| 45 | + sudo rm -rf /opt/az |
| 46 | + |
| 47 | + # Remove large tool caches (CodeQL will re-download only what it needs) |
| 48 | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
| 49 | + |
| 50 | + # Clean up system caches |
| 51 | + sudo apt-get clean |
| 52 | + sudo rm -rf /var/lib/apt/lists/* |
| 53 | + |
| 54 | + # Remove Docker images if Docker is installed (not needed for CodeQL) |
| 55 | + docker system prune -af || true |
| 56 | + |
| 57 | + # Remove pip cache |
| 58 | + rm -rf ~/.cache/pip || true |
| 59 | + |
| 60 | + # Remove npm cache (will be recreated during checkout if needed) |
| 61 | + npm cache clean --force || true |
| 62 | + |
| 63 | + echo "" |
| 64 | + echo "Disk space after cleanup:" |
| 65 | + df -h |
| 66 | +
|
| 67 | + - name: Checkout repository |
| 68 | + uses: actions/checkout@v4 |
| 69 | + |
| 70 | + # Initializes the CodeQL tools for scanning. |
| 71 | + - name: Initialize CodeQL |
| 72 | + uses: github/codeql-action/init@v4 |
| 73 | + with: |
| 74 | + languages: ${{ matrix.language }} |
| 75 | + build-mode: ${{ matrix.build-mode }} |
| 76 | + # Use our custom config file to exclude unnecessary files |
| 77 | + config-file: ./.github/codeql/codeql-config.yml |
| 78 | + |
| 79 | + - name: Perform CodeQL Analysis |
| 80 | + uses: github/codeql-action/analyze@v4 |
| 81 | + with: |
| 82 | + category: "/language:${{matrix.language}}" |
| 83 | + |
0 commit comments