Skip to main content

Change GitHub Action

org.openrewrite.github.ChangeAction

Change a GitHub Action in any workflow.

Recipe source

GitHub: ChangeAction.java, Issue Tracker, Code Genome Project

This recipe is available under the Moderne Source Available License. Moderne customers can download precompiled artifacts from The Code Genome Project. For non-commercial use you can build the artifact from source locally.

Options

TypeNameDescriptionExample
StringoldActionName of the action to match.gradle/wrapper-validation-action
StringoldShaOptional. Restricts the change by the existing uses: ref. When omitted, the action is changed regardless of how it is pinned (the default; commit SHA pins are rewritten). When set to an empty string, only references that are not pinned to a 40-character commit SHA are changed, leaving deliberate SHA pins on the original action untouched. When set to a specific commit SHA, only references pinned to exactly that SHA are changed.8f4b7f84864484a7bf31766abe9204da3cbe65b3
StringnewActionName of the action to use instead.gradle/actions/wrapper-validation
StringnewVersionNew version to use.v3

Used by

This recipe is used as part of the following composite recipes:

Example

Parameters
ParameterValue
oldActiongradle/wrapper-validation-action
oldShanull
newActiongradle/actions/wrapper-validation
newVersionv3
Before
.github/workflows/ci.yml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate wrapper
uses: gradle/wrapper-validation-action@v2
After
.github/workflows/ci.yml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate wrapper
uses: gradle/actions/wrapper-validation@v3

Usage

This recipe has required configuration parameters. Recipes with required configuration parameters cannot be activated directly (unless you are running them via the Moderne CLI). To activate this recipe you must create a new recipe which fills in the required parameters. In your rewrite.yml create a new recipe with a unique name. For example: com.yourorg.ChangeActionExample. Here's how you can define and customize such a recipe within your rewrite.yml:

rewrite.yml
---
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangeActionExample
displayName: Change GitHub Action example
recipeList:
- org.openrewrite.github.ChangeAction:
oldAction: gradle/wrapper-validation-action
oldSha: 8f4b7f84864484a7bf31766abe9204da3cbe65b3
newAction: gradle/actions/wrapper-validation
newVersion: v3

Now that com.yourorg.ChangeActionExample has been defined, activate it and take a dependency on org.openrewrite.recipe:rewrite-github-actions:3.29.0 in your build file:

OpenRewrite artifacts are distributed through the Code Genome Project repository (https://artifacts.codegenomeproject.org/maven), which requires authentication. Sign in to the Code Genome Project to create a download token, then in the snippets below replace USERNAME with the email or username you signed in with and TOKEN with that token. See the quickstart guide for details.

  1. Add the following to your build.gradle file:
    build.gradle
    plugins {
    id("org.openrewrite.rewrite") version("latest.release")
    }

    rewrite {
    activeRecipe("com.yourorg.ChangeActionExample")
    setExportDatatables(true)
    }

    repositories {
    mavenCentral()
    maven {
    url = "https://artifacts.codegenomeproject.org/maven"
    credentials {
    username = "USERNAME"
    password = "TOKEN"
    }
    }
    }

    dependencies {
    rewrite("org.openrewrite.recipe:rewrite-github-actions:3.29.0")
    }
  2. Run gradle rewriteRun to run the recipe.

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables

Source files that had results

org.openrewrite.table.SourcesFileResults

Source files that were modified by the recipe run.

Column NameDescription
Source path before the runThe source path of the file before the run. null when a source file was created during the run.
Source path after the runA recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run.
Parent of the recipe that made changesIn a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all.
Recipe that made changesThe specific recipe that made a change.
Estimated time savingAn estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds.
CycleThe recipe cycle in which the change was made.