# Add OpenSSF Scorecard to a Repository with GitHub Actions

Yes. An agent adds the OpenSSF Scorecard workflow, publishes its results to code scanning, pins every action by commit so the checks pass, and opens a pull request.

[Run this on Rush](https://cloud.getrush.ai/run/add-openssf-scorecard/github-actions/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads every workflow before it adds one, because Scorecard grades the repository as a whole and most of its findings are about files that already exist. In a repository started from actions/typescript-action there are five workflows: `ci.yml` runs format, lint and Jest on the Node version in `.node-version`, which is `24.4.0`; `check-dist.yml` rebuilds `dist/` with Rollup and fails on a diff; `codeql-analysis.yml` runs `github/codeql-action` on `src` with a weekly cron; `linter.yml` runs super-linter's slim image with `.checkov.yml` and a `VALIDATE_GITHUB_ACTIONS_ZIZMOR: false` switch; and `licensed.yml` checks cached licenses on `workflow_dispatch`. Each sets top-level `permissions` with `contents: read`, and `.github/dependabot.yml` already updates `github-actions` and `npm` weekly in groups. `CODEOWNERS` and `LICENSE` exist; there is no `SECURITY.md` and no Scorecard workflow.

With that inventory the agent knows which Scorecard checks the repository will pass as it is, which it can fix in the diff, and which depend on settings it cannot reach. Dependency-Update-Tool, SAST, License and the per-workflow Token-Permissions are in place. Pinned-Dependencies is not: every `uses:` line references a tag such as `actions/checkout@v6`, `actions/setup-node@v6`, `github/codeql-action/init@v4`, `ruby/setup-ruby@v1`, `super-linter/super-linter/slim@v8` and `actions/upload-artifact@v7`, and Scorecard wants a commit SHA. The agent resolves each tag to the commit it points at with the GitHub API and rewrites it as `@<sha> # vX.Y.Z`, the comment form Dependabot keeps updated, so the groups in `dependabot.yml` carry on working. Security-Policy it fixes by adding a short `SECURITY.md` that says where to report a vulnerability, with a placeholder contact the reviewer fills in. Branch-Protection, Code-Review and Signed-Releases live in repository settings and release practice, so the pull request explains them rather than pretending to fix them.

The new `.github/workflows/scorecard.yml` runs `ossf/scorecard-action`, itself pinned by SHA, on pushes to the default branch, on `branch_protection_rule` events and on a weekly schedule, with `permissions` limited to `security-events: write` for the SARIF upload, `id-token: write` so `publish_results: true` can sign the result, and `contents: read` and `actions: read` for the checks that read workflows and runs. The SARIF goes to code scanning through `github/codeql-action/upload-sarif`, the same action family the CodeQL workflow already uses, so findings appear next to CodeQL's in the Security tab. The agent also notes the `actionlint.yml` rule that ignores `invalid runner name "node24"`, since `action.yml` declares `runs.using: node24`, and leaves it in place.

To check its own work, the agent runs `actionlint` over all six workflows in its sandbox, runs `zizmor` on them because super-linter has that check switched off, and, where the repository is public, runs the Scorecard CLI against the branch to see which checks moved. It cannot see the published result for the pull request branch, because publishing happens only on the default branch, so the description says which checks it expects to change and why.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add OpenSSF Scorecard to this repository. Read every workflow under .github/workflows, .github/dependabot.yml, action.yml, actionlint.yml and CODEOWNERS first. Add a scorecard workflow that runs on pushes to the default branch, branch protection changes and a weekly schedule, uploads the SARIF to code scanning and publishes results, with the smallest permissions that allows. Then fix what Scorecard would flag in the files themselves: pin every action in every workflow to a commit SHA with a version comment that Dependabot can keep updated, and add a SECURITY.md. Run actionlint and zizmor on the workflows. Do not change repository settings; list the checks that need them in the pull request, and open it.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on its own branch adding `.github/workflows/scorecard.yml` and `SECURITY.md`, and touching each existing workflow only on its `uses:` lines, where tags become commit SHAs with version comments. The steps, permissions and triggers of the existing workflows are unchanged, so CI, CodeQL, the linter and the dist check keep doing what they did.

The description has a table of the Scorecard checks: the ones the repository passed already, the ones this diff addresses and the ones that need a setting, with the setting named for each, such as branch protection on the default branch requiring reviews. It quotes the `actionlint` and `zizmor` output and, when it could run the Scorecard CLI, the before and after for the checks it changed. It also adds the Scorecard badge to the README in a form that renders after the first run on the default branch.

Before merging, a reviewer confirms each SHA matches the version in its comment, decides whether `id-token: write` is acceptable in that repository, and fills in the contact in `SECURITY.md`; after merging, the first scheduled run publishes the score and the badge starts showing it.

## Run it on every new repository in your organization

GitHub signs its webhooks and cannot add the `Authorization` header a Rush `webhook` trigger requires, so a small handler on your server receives the organization's `repository` event, checks its signature and sends this body to `POST /o/{org}/sessions` with the new repository in `resources`. It sends a `request_id` that is a UUID v5 of the delivery id, so GitHub's retries return the run already started instead of starting another.

With a `webhook_url` on the key, Rush POSTs `run.completed` when the turn ends; the handler reads the pull request from the session and posts it where the repository's owners will see it. Every repository created in the organization then starts with Scorecard and pinned actions from its first week, with the transcript showing what was checked.

## Why run it on Rush?

Scorecard is one workflow to add and a dozen checks to understand, and the understanding is the work: which findings are about files, which about settings, and how to pin actions without breaking the Dependabot groups that keep them current. The agent reads all five workflows and the Dependabot config first, so the pull request fixes what a diff can fix and says plainly what it cannot.

On Rush the pinning, the linting and the local Scorecard run happen in the agent's own sandbox with the real tools, and the transcript keeps every command and its output next to the diff. An organization with many repositories can hand each one to its own run, each with its own sandbox and its own pull request, rather than copying one workflow around by hand.

## Frequently asked questions

### Why does the workflow need id-token: write?

Publishing results to the OpenSSF API signs them with the workflow's OIDC token, so `publish_results: true` needs `id-token: write`. Without publishing, the SARIF upload to code scanning still works and only `security-events: write` is needed; the pull request says which mode it set and how to switch.

### Will Dependabot still update the pinned actions?

Yes. Dependabot updates SHA pins when the line carries a version comment, and the agent writes every pin as `@<sha> # vX.Y.Z`. The existing weekly `github-actions` entry with its minor and patch group applies to the new workflow as well.

### Which checks cannot be fixed from the repository?

Branch-Protection, Code-Review and Signed-Releases depend on settings and release practice, and Maintained on activity. The pull request lists each with the setting to change, such as requiring a review before merging to the default branch, instead of adding files that would not move the score.

### Does the score show on the pull request?

No. The Scorecard action publishes only from the default branch, so the pull request shows the workflow and the pinned actions, and the first run after merge produces the score and the badge. The agent's local run of the Scorecard CLI, where it could do one, is quoted in the description as a preview.

## More GitHub Actions jobs

- [Add a Release Workflow to a Custom GitHub Action](https://getrush.ai/run/add-release-workflow/github-actions/)
- [Post Slack Alerts When GitHub Actions Workflows Fail](https://getrush.ai/run/add-slack-failure-alerts/github-actions/)
- [Add zizmor to CI for Your GitHub Actions Workflows](https://getrush.ai/run/add-zizmor-to-ci/github-actions/)

## The same job on other stacks

- [Add OpenSSF Scorecard to a Python Project](https://getrush.ai/run/add-openssf-scorecard/python/)
- [Add OpenSSF Scorecard to a TypeScript Library](https://getrush.ai/run/add-openssf-scorecard/typescript-library/)

## More jobs like this: Hand off a long task

- [Add OpenTelemetry Tracing to an Actix Web App](https://getrush.ai/run/add-opentelemetry/actix/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
