Search and rename files and content via actions

Hi all :grinning:

I’m just starting my work with GitHub and I think it’s really great. Working with “actions/workflows” I’m wondering if it’s possible to search and rename files and content of a repository using the actions feature.

Here is an example structure:

  • Core
    ** base.php => In line 3 stands “product name”.
  • Variants (folder)
    ** Product name (folder)
    *** productname.php (rename file name and in line 3 is again “productname”)
  • Output (Here the renamed files should arrive)

How is it possible via actions to search for the “product name” and replace it with a variable like “Dark”? The changes must then be saved in the Output folder.

I am happy to receive feedback :slight_smile:

You can edit files with whatever tools you like (e.g. grep and sed to search or replace), then add, commit, and push the changes as you would on your machine. Remember that renaming files will require git mv instead of mv so Git picks up the renaming.

The actions/checkout repository has an example of how to create commits in a workflow. The only thing that’s slightly different from committing at the command line is that you need to configure the user information some time before you commit.

Note that this will only work with a token that has write access for repository content. For the default GITHUB_TOKEN, see: Permissions for the GITHUB_TOKEN

1 Like