Adding Codacy to GitHub Actions
Run Codacy quality checks and push coverage from your GitHub Actions workflow.
Codacy provides automated code review and coverage reporting. You can run its CLI analysis action locally in CI or just upload coverage with the coverage-reporter action. Both need a project API token stored as a secret.
What you need
- A CODACY_PROJECT_TOKEN secret from your Codacy project settings.
- A coverage report (lcov, coverage.xml, or jacoco.xml) if uploading coverage.
- The codacy/codacy-analysis-cli-action or codacy/codacy-coverage-reporter-action.
The workflow
Upload coverage after your tests produce a report:
.github/workflows/ci.yml
- name: Test
run: npm test -- --coverage
- name: Upload coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage/lcov.infoRun analysis
To run Codacy linters in CI and produce SARIF for the Security tab:
.github/workflows/ci.yml
- uses: codacy/codacy-analysis-cli-action@v4
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
format: sarif
output: results.sarifCommon gotchas
- The project token is per-repository - reusing one across repos sends data to the wrong project.
- The coverage reporter expects a supported format; mixed formats need the multiple coverage-reports input.
- The analysis CLI pulls Docker images, adding minutes - pin a runner with Docker preinstalled.
Key takeaways
- Codacy uses a per-project API token stored as a secret.
- Use codacy-coverage-reporter-action to push lcov/xml coverage.
- codacy-analysis-cli-action can emit SARIF for the GitHub Security tab.
Related guides
Adding SonarQube and SonarCloud to GitHub ActionsRun SonarCloud (or self-hosted SonarQube) analysis in GitHub Actions with the official scan action, a SONAR_T…
Adding Code Climate to GitHub ActionsReport test coverage to Code Climate from GitHub Actions using the test-reporter binary, before-build and aft…
Adding Codecov to GitHub ActionsUpload code coverage to Codecov from a GitHub Actions workflow: generate an lcov/Cobertura report, add the co…