Pin GitHub Actions to commit SHAs
Recipe ID
org.openrewrite.github.security.PinGitHubActionsToShaArtifact
org.openrewrite.recipe:rewrite-github-actionsReplaces mutable tag or branch references in GitHub Actions uses: declarations with immutable commit SHAs. A static mapping of well-known actions is checked first; if the action is not found, the GitHub API is used to resolve the reference at recipe run time. By default only third-party actions are pinned; set pinOfficialActions to include actions from the actions and github organizations. To pin only a specific allow-list of actions, set includedActions.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.github.security.PinGitHubActionsToShaIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-github-actions:3.28.0Options
| Name | Type | Description |
|---|---|---|
pinOfficialActions | Boolean | When set to true, also pins actions from official GitHub organizations (e.g., actions/*, github/*). Defaults to false, meaning only third-party actions are pinned. |
githubApiToken | String | A GitHub personal access token used to resolve tags/branches to commit SHAs via the GitHub API. Only needed for actions not found in the built-in static mapping. Without a token, unauthenticated requests are rate-limited to 60/hour. e.g. TODO Provide a usage example for the docs |
trustedOwners | List | Optional list of trusted owners/organizations, actions that belong to these organizations will not be pinned. This option overrides the 'Included actions' list. e.g. my-organization, my-other-organization |
includedActions | List | Optional allow-list of actions to pin. When provided, only uses: references matching one of these patterns are pinned; all other actions are left untouched. Patterns may be owner/repo (exact match), owner/* (any repo in an org), or owner/repo/subpath (exact match including a subpath). When omitted or empty, all third-party actions (and optionally official actions, per pinOfficialActions) are pinned.e.g. codecov/codecov-action |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats