What You Will Have at the End
By the end of this guide, every time your pipeline builds or releases something, the files it produces are scanned for malware by ClamAV, YARA and an image-payload check before they ship. Specifically:
- A workflow step that scans your build output and fails the build if anything is infected.
- An annotation on each infected file and a results table on the job's summary page in GitHub.
- A JSON report listing every file's verdict, threat names, SHA-256 and scan ID.
- Every scan listed on your CI/CD page in the dashboard, grouped by GitHub owner, then repository, then workflow run, and linked back to the commit and the run.
The whole setup takes about ten minutes. You need:
- A Virus Purge account on an Enterprise plan (step 1).
- Admin access to the GitHub repository, so you can add a secret and a workflow file.
- A pipeline that produces files worth scanning: a
dist/folder, release archives, installers, container build context, and so on.
Step 1: Check That You Are on an Enterprise Plan
CI/CD scanning is an Enterprise feature. Enterprise means a Premium plan with a purchased daily scan volume: either an Enterprise team on your personal account, or an organization with an active subscription.
To check, open the CI/CD page in the dashboard sidebar (under Developers):
- If you see "No pipeline scans yet" or a list of repositories, you are on Enterprise and can continue.
- If you see "CI/CD integration is an Enterprise feature", you need to upgrade first. On your personal account, follow See Enterprise plans. For an organization, its Founder or a member with the Billing role can upgrade it on the organization's Billing tab.
If you skip this step, the scan step will fail with 403 and the error code enterprise_required. Plain Premium can still use the REST API and the CLI outside of a pipeline, just not CI/CD.
Step 2: Decide Which API Key the Pipeline Will Use
Where the results show up depends on which key the workflow uses. Pick one:
| Key | Starts with | Where to get it | Results appear on |
|---|---|---|---|
| Personal key | vp_ | Dashboard → API Keys | Your own CI/CD page (/dashboard/ci) |
| Organization key | vpo_ | Organizations → your organization → API keys tab | That organization's CI/CD tab |
Use an organization key for team repositories. That way the scans count against the organization's shared daily volume, everyone with access to the organization can see the results, and nothing breaks if the person who set it up leaves.
Getting a personal key
- Open API Keys in the sidebar.
- Click Reveal, then the copy button next to the key.
Getting an organization key
- Open Organizations in the sidebar and choose the organization.
- Go to the API keys tab. Creating a key needs the Manage API keys permission. If you don't have it, ask the organization's Founder or an admin.
- Create a key with a name that says what it is for, such as
github-actions, and copy its value.
Keep the key somewhere safe for the next step. Never paste it into a workflow file or commit it to the repository. Anyone with the key can scan on your account's quota.
Step 3: Store the Key as a GitHub Secret
GitHub Actions reads credentials from encrypted secrets, which are masked in logs.
- In GitHub, open your repository and go to Settings.
- In the left sidebar, open Secrets and variables → Actions.
- Click New repository secret.
- Name:
VIRUSPURGE_API_KEY - Secret: paste the key from step 2.
- Click Add secret.
If you want to use one key across many repositories, create it as an organization secret instead (your GitHub organization's Settings → Secrets and variables → Actions) and give the repositories that need it access. The name stays the same.
The action also masks the key itself, so it never shows up in the run log even if a later step prints its inputs.
Step 4: Add the Scan Step to a Workflow
Workflows live in the .github/workflows/ folder of your repository. You can add the scan step to a workflow you already have, right after the step that builds your files. Or you can create a new file.
Here is a complete, working example for a project that builds into dist/. Save it as .github/workflows/virus-scan.yml:
name: Build and scan
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Build
run: |
npm ci
npm run build
- name: Scan the build output for malware
id: scan
uses: decentralisoft/virus-scanner-cicd-action@v1
with:
api-key: ${{ secrets.VIRUSPURGE_API_KEY }}
files: |
dist/**
!dist/**/*.map
What each part does:
on:chooses when the workflow runs: on every push tomain, on every pull request, and manually from the Actions tab (workflow_dispatch).- Build is your existing build. Replace it with whatever produces your files, for example
cargo build --release,go build,mvn packageordocker save. uses: decentralisoft/virus-scanner-cicd-action@v1is the Virus Purge Scan action. Pinning to@v1gets you fixes without breaking changes.api-keyreads the secret you created in step 3.fileslists what to scan, one entry per line. An entry can be a file, a directory (scanned recursively) or a glob pattern. A line starting with!excludes matches. Here, source maps are skipped because they are plain text and only use up quota.id: scanlets later steps read the action's outputs (see step 7).
Paths are relative to the repository root (the GITHUB_WORKSPACE). Glob patterns support , *, ?, [abc] and {a,b}. .git directories are never scanned, and empty files are skipped rather than counted.
A few files examples:
files: dist/ # everything under dist/
files: build/**/*.{zip,exe,msi,dmg} # only installers and archives
files: |
out/app.AppImage
out/app-setup.exe
release/**
!release/**/*.txt
Commit the file and push it to GitHub.
Step 5: Run It and Read the Result in GitHub
The push triggers the workflow. To run it by hand, open the Actions tab, choose Build and scan and click Run workflow.
Open the run once it starts. In the scan step's log you will see one line per file:
Scanning 30 files with Virus Purge…
clean dist/index.html
clean dist/assets/app-4f2a.js
...
30 scanned: 30 clean, 0 infected, 0 failed, 0 skipped.
When the run finishes, its Summary page has a Virus Purge scan section. It starts with a one-line verdict ("All 30 files clean."), then a table of every file with its result, the threat name if there is one, and the scan ID. Infected and failed files are listed first.
If malware is found:
- The step fails, so the job fails and anything after it (publishing, deploying) does not run.
- Each infected file gets an error annotation titled Malware detected with the threat name, shown on the run summary and, for pull requests, in the Checks tab.
Step 6: See the Results on Your CI/CD Page
Open CI/CD in the Virus Purge dashboard. For an organization key, open the organization's CI/CD tab instead. Results are organized the way a team thinks about them:
- Owners and repositories. One card per GitHub owner (a user or an organization), listing its repositories with the last run's result, the number of runs, files scanned, infected files and last activity.
- Runs. Click a repository to see its workflow runs: the workflow name, run number, result, branch or tag, commit (linked to GitHub), number of files, who triggered it and when it started. A re-run of the same workflow run shows as a separate attempt (
#1234 · attempt 2). - Files. Click a run to see every file it scanned, with the verdict and a link to each scan's full report. Open run takes you back to the run on GitHub.
Each level has its own URL, so you can bookmark a repository or send a run to a colleague who has the same access.
The page shows scans made with the key from step 2. If you used a personal key on a team repository, the scans are on your personal CI/CD page, not the organization's. The organization's CI/CD tab tells you when that happens. Switch the secret to an organization key and future runs will appear there.
Step 7: Tune the Behaviour
All inputs
| Input | Default | What it does |
|---|---|---|
api-key | none | Required. Your Virus Purge key. Always pass it from a secret. |
files | none | Required. Files, directories or globs, one per line. Prefix with ! to exclude. |
fail-on-infected | true | Fail the step when malware is found. |
fail-on-error | true | Fail the step when a file could not be scanned (network error, file too large, quota reached). |
if-no-files-found | error | What to do when nothing matches files: error, warn or ignore. |
concurrency | 4 | How many files are scanned in parallel. |
timeout | 120 | Seconds to wait for a verdict if an upload connection drops. The verdict is fetched by scan ID instead of being lost. |
api-url | https://viruspurge.com | Only change this if you were told to. |
All outputs
| Output | Value |
|---|---|
result | clean, infected, error, or none when nothing was scanned |
scanned | Number of files scanned |
infected | Number of infected files |
errors | Number of files that could not be scanned |
report | Path to the JSON report on the runner |
Keep the JSON report as a build artifact
Add this after the scan step. if: always() makes it run even when the scan failed the job, which is exactly when you want the report:
- name: Upload the scan report
if: always() && steps.scan.outputs.report != ''
uses: actions/upload-artifact@v4
with:
name: virus-scan-report
path: ${{ steps.scan.outputs.report }}
Report without failing the build
While you roll scanning out, you may want results without blocking anyone. Set:
fail-on-infected: false
fail-on-error: false
You can then react to the outputs yourself, for example to post a warning:
- name: Warn about infected files
if: steps.scan.outputs.result == 'infected'
run: echo "::warning::${{ steps.scan.outputs.infected }} infected file(s) found. See the job summary."
Turn the defaults back on once you trust the results. Shipping an infected file should fail the build.
Scan release assets before anyone downloads them
This workflow runs whenever you publish a GitHub release. It downloads the release's assets, scans them, and attaches the report to the release so your users can see it:
name: Scan release artifacts
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: write # to upload the report to the release
jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Download the release assets
env:
GH_TOKEN: ${{ github.token }}
run: gh release download "${{ github.event.release.tag_name }}" --repo "$GITHUB_REPOSITORY" --dir dist
- name: Scan for malware
id: scan
uses: decentralisoft/virus-scanner-cicd-action@v1
with:
api-key: ${{ secrets.VIRUSPURGE_API_KEY }}
files: |
dist/**
- name: Attach the scan report to the release
if: always() && steps.scan.outputs.report != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
cp "${{ steps.scan.outputs.report }}" virus-scan-report.json
gh release upload "${{ github.event.release.tag_name }}" virus-scan-report.json --clobber --repo "$GITHUB_REPOSITORY"
A stronger pattern is to scan before publishing: build the assets, scan them in the same job, and only run the release step if the scan passed. A failed scan stops the job, so a release step placed after the scan never runs on infected files.
Pull requests from forks
GitHub does not give secrets to workflows triggered by pull requests from forks. Without a key, the scan step fails with 401 Invalid API key. To skip the scan for fork PRs and still run it everywhere else, add a condition to the step:
- name: Scan the build output for malware
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: decentralisoft/virus-scanner-cicd-action@v1
with:
api-key: ${{ secrets.VIRUSPURGE_API_KEY }}
files: dist/**
Don't work around this with pull_request_target. It runs untrusted fork code with your secrets.
Using GitLab CI Instead
On GitLab, use the viruspurge CLI. It detects GitLab CI by itself and sends the project path, branch, commit, job name, pipeline ID and URL, so runs are organized on your CI/CD page the same way as on GitHub.
- In your GitLab project, go to Settings → CI/CD → Variables and click Add variable.
- Key:
VIRUSPURGE_API_KEY. Value: your key. Tick Mask variable. If you also tick Protect variable, the key is only available to pipelines on protected branches and tags. - Add a job to
.gitlab-ci.ymlthat runs after your build:
virus-scan:
stage: test
image: node:22
needs: [build] # the job that produces dist/
script:
- npx --yes viruspurge scan dist/ '!dist/**/*.map' --report virus-scan-report.json
artifacts:
when: always
paths:
- virus-scan-report.json
The CLI reads the key from the VIRUSPURGE_API_KEY variable. Don't pass it with --api-key, because that shows up in process lists. It needs Node 20 or newer and has no other dependencies.
The job fails when malware is found. Exit codes:
| Exit code | Meaning |
|---|---|
0 | Every file is clean (empty files are skipped) |
1 | Malware was found |
2 | A file could not be scanned, the API refused the request, or the command was used wrong |
Add --no-fail-on-error to tolerate files that could not be scanned. --concurrency <n> and --timeout <seconds> work like the action's inputs, and --json prints machine-readable output.
Other CI Systems
The CLI runs anywhere Node 20+ does: Jenkins, CircleCI, Azure Pipelines, Bitbucket Pipelines, Buildkite or your own scripts. The command and exit codes are the same as above, so a failed scan fails the build.
Today, pipeline context is detected automatically only on GitHub Actions and GitLab CI. On other systems the scans still run and show up in your Scan history, but they are not grouped on the CI/CD page.
Limits Worth Knowing
- File size: up to 256 MB per file. Larger files are reported as failed scans, and with
fail-on-error: truethey fail the step. Split them, or scan their contents before packaging. - Daily volume: every scanned file counts as one scan against the daily volume of the key's account or organization. Excluding things that can't carry malware (source maps,
.txt, checksums) saves quota. When the volume runs out, scans fail with429until the next day. - Archives are scanned, including their contents.
- Your files never pass through our web servers. Each file is uploaded directly to an isolated scanner with a short-lived signed permit.
Troubleshooting
"CI/CD integration … requires an Enterprise plan" (403 enterprise_required)
The account or organization that owns the key is not on Enterprise. Check step 1. If you upgraded recently, make sure the secret holds a key for the account you upgraded. A personal key on an upgraded organization will not work, and neither will the other way round.
"Invalid API key." (401)
- The secret name in the workflow doesn't match the one you created (
VIRUSPURGE_API_KEY, case-sensitive). - The key was regenerated. Regenerating stops the old value immediately, so update the secret.
- The run is a pull request from a fork, which gets no secrets (see above).
"No files match 'dist/**'" / "No files to scan."
The patterns matched nothing, so the step fails (that is what if-no-files-found: error does). Usually:
- The build didn't run, or wrote somewhere else. Add
- run: ls -Rbefore the scan step to see what is really there. - The paths are relative to the repository root, not to a
working-directoryyou set on an earlier step. Include the subfolder:frontend/dist/**. - The files were built in a different job. Every job runs on a fresh machine. Upload the files with
actions/upload-artifactin the build job and download them withactions/download-artifactin the scan job, or scan in the same job.
Files show "Scan failed"
Look at the Detail column in the job summary. Common causes are a file over 256 MB, the daily volume being used up (429), or a network problem. Dropped uploads are already retried by fetching the verdict by scan ID for up to timeout seconds. On slow runners, raise timeout or lower concurrency.
The run passed but nothing appears on the CI/CD page
- You are looking at the wrong page. A personal
vp_key shows on your own CI/CD page and an organizationvpo_key on that organization's CI/CD tab. - The scans came from a CI system other than GitHub Actions or GitLab CI, so they are in Scan history instead.
- The step was skipped, for example by an
if:condition. Check that it actually ran in the run log.
A file is flagged and I believe it is clean
Open the file's scan from the run's file list to see which engine flagged it and the threat name. Treat it as real until proven otherwise: here is what to do if you find malware. If you are sure it is a false positive, contact us with the scan ID.
Summary Checklist
- Confirm you're on Enterprise: the CI/CD page shows no upgrade prompt.
- Copy a key: organization
vpo_for team repositories, personalvp_for your own. - Add it to GitHub as the secret
VIRUSPURGE_API_KEY. - Add the
decentralisoft/virus-scanner-cicd-action@v1step right after your build, withfilespointing at the build output. - Push, then check the job Summary in GitHub.
- Open CI/CD in the dashboard to browse results by owner, repository and run.
For the full API reference, including the ci object the action sends and webhooks that tell you about infected files as they happen, see the API documentation.