Step 1: choose the trigger
The example runs weekly on a cron schedule (Mondays at 02:00 UTC) and on manual dispatch. A schedule suits adaptive pentests, which take longer than a typical pull request check. If you want a run after each staging deploy, trigger the workflow from your deployment job instead. Avoid running dynamic tests on pull requests from forks, which should never see your secrets.
Step 2: set permissions and secrets
- Grant
contents: readandsecurity-events: write; the second is required to upload SARIF to Code Scanning. - Store the model API key as an encrypted repository or organisation secret, for example
ANTHROPIC_API_KEY. - Store the target and scope as repository variables (
PENTEST_TARGET,PENTEST_SCOPE) so they are not hard-coded. - Restrict who can edit those variables; changing them changes what gets tested.
Step 3: add the pentest step
- Use
Armur-Ai/Pentest-Swarm-AI@v0with inputstarget,scope,mode(manual, bugbounty, asm or ctf) andfail-on(critical, high, medium, low or none). - Set
swarm: "true"to use the swarm scheduler, or leave it off for the stable sequential runner. - Use
dry-run: "true"for a first trial, which plans without executing exploitation commands. - Pin a release with the
versioninput once you are happy with results, so upgrades are deliberate.
Step 4: publish the results
Upload the report directory as a build artifact with actions/upload-artifact, using if: always() so you keep it even when the severity gate fails the job. Then upload the SARIF file with github/codeql-action/upload-sarif, reading the path from the action's sarif-path output. Findings then appear in the repository's Security tab alongside any static analysis results.
Common mistakes to avoid
- Running against production because a variable was left at its default. Keep the production hostname out of the workflow entirely.
- Triggering on
pull_request_targetor fork pull requests, which can expose secrets to untrusted code. - Leaving the job without a
timeout-minutesvalue, so a long adaptive run ties up a runner. - Uploading SARIF only on success, which hides results exactly when the severity gate fails.
- Floating on the latest release forever; pin a version once the workflow is stable.
What the Pentest-Swarm action provides
The action installs a Pentest-Swarm release on the runner and runs a scan with your inputs. It is marked beta in the project's feature table.
- Outputs:
report-path(Markdown report),sarif-path(for Code Scanning) andfindings-count. - Scope is enforced in code and fails closed, so the run cannot drift beyond
PENTEST_SCOPE. - Copy the example from
deploy/github-action/example-workflow.ymlin the repository into.github/workflows/pentest.yml. - Prefer to run it locally first?
npm install -g @armurai/pentestswarmandpentestswarm scan $TARGET --scope $SCOPE --follow.
Where it falls short
The GitHub Action is beta and its api-key input is documented as a Claude API key; for other providers, running the CLI directly in a workflow step gives you more control. GitHub-hosted runners can only reach internet-accessible targets, so testing internal staging needs a self-hosted runner inside that network. Adaptive runs vary in length, so set a job timeout. For a quick, deterministic DAST check on every pull request, a dedicated DAST action is a better fit.
Questions
Why do I need security-events: write?
GitHub requires that permission for a workflow to upload SARIF results to Code Scanning.
Can a GitHub Actions pentest test internal services?
Not from GitHub-hosted runners. Use a self-hosted runner placed inside the network that can reach the target.
Will the job fail on every finding?
Only on findings at or above the fail-on severity; others are reported but do not fail the job.