github/codeql-action/analyze@v4
Finalize CodeQL database
At a glance
- Latest major
v4- Repository
- github/codeql-action
- Inputs
- 18 (1 required)
- Outputs
- 3
- Runs using
node24- License
- MIT
- Last checked
Inputs and outputs come straight from the action's official action.yml. See our editorial standards.
Usage
- uses: github/codeql-action/analyze@v4Inputs
| Name | Required | Default | Description |
|---|---|---|---|
check_name | No | none | The name of the check run to add text to. |
output | No | ../results | The path of the directory in which to save the SARIF results from the CodeQL CLI. |
upload | No | always | Upload the SARIF file to Code Scanning. Defaults to 'always' which uploads the SARIF file to Code Scanning for successful and failed runs. 'failure-only' only uploads debugging information to Code Scanning if the workflow run fails, for users post-processing the SARIF file before uploading it to Code Scanning. 'never' avoids uploading the SARIF file to Code Scanning, even if the code scanning run fails. This is not recommended for external users since it complicates debugging. |
cleanup-level | No | none | DEPRECATED. This option is ignored since, for performance reasons, the CodeQL Action automatically manages cleanup of intermediate results. |
ram | No | none | The amount of memory in MB that can be used by CodeQL for database finalization and query execution. By default, this action will use the same amount of memory as previously set in the "init" action. If the "init" action also does not have an explicit "ram" input, this action will use most of the memory available in the system (which for GitHub-hosted runners is 6GB for Linux, 5.5GB for Windows, and 13GB for macOS). |
add-snippets | No | none | Deprecated The input "add-snippets" has been removed and no longer has any effect. |
skip-queries | No | false | If this option is set, the CodeQL database will be built but no queries will be run on it. Thus, no results will be produced. |
threads | No | none | The number of threads that can be used by CodeQL for database finalization and query execution. By default, this action will use the same number of threads as previously set in the "init" action. If the "init" action also does not have an explicit "threads" input, this action will use all the hardware threads available in the system (which for GitHub-hosted runners is 2 for Linux and Windows and 3 for macOS). |
checkout_path | No | ${{ github.workspace }} | The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file. |
ref | No | none | The ref where results will be uploaded. If not provided, the Action will use the GITHUB_REF environment variable. If provided, the sha input must be provided as well. This input is ignored for pull requests from forks. Expected format: refs/heads/<branch name>, refs/tags/<tag>, refs/pull/<number>/merge, or refs/pull/<number>/head. |
sha | No | none | The sha of the HEAD of the ref where results will be uploaded. If not provided, the Action will use the GITHUB_SHA environment variable. If provided, the ref input must be provided as well. This input is ignored for pull requests from forks. |
category | No | none | String used by Code Scanning for matching the analyses |
upload-database | No | true | Whether to upload the resulting CodeQL database |
post-processed-sarif-path | No | none | Before uploading the SARIF files produced by the CodeQL CLI, the CodeQL Action may perform some post-processing on them. Ordinarily, these post-processed SARIF files are not saved to disk. However, if a path is provided as an argument for this input, they are written to the specified directory. |
wait-for-processing | Yes | true | If true, the Action will wait for the uploaded SARIF to be processed before completing. |
token | No | ${{ github.token }} | GitHub token to use for authenticating with this instance of GitHub. The token must be the built-in GitHub Actions token, and the workflow must have the `security-events: write` permission. Most of the time it is advisable to avoid specifying this input so that the workflow falls back to using the default value. |
matrix | No | ${{ toJson(matrix) }} | No description in action.yml. |
expect-error | No | false | [Internal] It is an error to use this input outside of integration testing of the codeql-action. |
Outputs
| Name | Description |
|---|---|
db-locations | A map from language to absolute path for each database created by CodeQL. |
sarif-output | Absolute, local path to the directory containing the generated SARIF file. |
sarif-id | The ID of the uploaded SARIF file. |
Read an output with ${{ steps.<step-id>.outputs.<name> }}; the step needs an id.
Examples
Finish the CodeQL scan
Runs the queries and uploads results to the Security tab; needs `init` first.
name: Example
on:
push:
branches: [main]
permissions:
contents: read
security-events: write
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: github/codeql-action/init@v4
with:
languages: javascript-typescript
- name: "CodeQL: Finish"
uses: github/codeql-action/analyze@v4
with:
category: "/language:javascript-typescript"Each example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.
Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.