• Stars
    star
    105
  • Rank 327,414 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A GitHub Action to find and replace strings in project files.

Find and Replace Action

GitHub Marketplace Actions Status Actions Status

This action will find and replace strings in your project files.

Usage

Example workflow

This example replaces hello with world in all of your project files.

name: My Workflow
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Find and Replace
        uses: jacobtomlinson/gha-find-replace@v3
        with:
          find: "hello"
          replace: "world"
          regex: false

Inputs

Input Description
find A string to find and replace in your project files. (Defaults to a regular expression.)
replace The string to replace it with.
include (optional) A glob of files to include. Defaults to **.
exclude (optional) A glob of files to exclude. Defaults to .git/** .
regex (optional) Whether to match with.find as a regular expression instead of a fixed string. Defaults to true.

Outputs

Output Description
modifiedFiles The number of files that have been modified

Examples

Including a subdirectory

You can limit your find and replace to a directory.

name: My Workflow
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Find and Replace
        uses: jacobtomlinson/gha-find-replace@v3
        with:
          find: "hello"
          replace: "world"
          include: "justthisdirectory/**"
          regex: true

Filter by file name

You can limit your find and replace to just files with a specific name.

name: My Workflow
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Find and Replace
        uses: jacobtomlinson/gha-find-replace@v3
        with:
          find: "hello"
          replace: "world"
          include: "**README.md" # Will match all README.md files in any nested directory

Exclude by file type

You can set your find and replace to ignore certain file types.

name: My Workflow
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Find and Replace
        uses: jacobtomlinson/gha-find-replace@v3
        with:
          find: "hello"
          replace: "world"
          exclude: "**/*.py" # Do not modify Python files

Pushing changes back

Any modifications during a GitHub Actions workflow are only made to the working copy checked out by the actions/checkout step. If you want those changes to be pushed back to the repository you'll need to add a final step that does this.

name: My Workflow
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Find and Replace
        uses: jacobtomlinson/gha-find-replace@v3
        with:
          find: "hello"
          replace: "world"
          regex: false
      - name: Push changes
        uses: ad-m/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}

If you need the push event to trigger other workflows, use a repo scoped Personal Access Token.

      - name: Push changes
        uses: ad-m/[email protected]
        with:
          github_token: ${{ secrets.MY_PAT }}
          branch: ${{ github.ref }}

Publishing

To publish a new version of this Action we need to update the Docker image tag in action.yml and also create a new release on GitHub.

  • Work out the next tag version number.
  • Update the Docker image in action.yml.
  • Create a new release on GitHub with the same tag.

More Repositories

1

carte-noire

A simple jekyll theme for blogging
CSS
296
star
2

gpu-python-tutorial

GPU Development in Python 101 tutorial
Jupyter Notebook
119
star
3

krontab

โฐ A crontab like editor for Kubernetes cron jobs
Go
96
star
4

terminal-piperita

The "Piperita" terminal theme
JavaScript
94
star
5

python-container-action

A template for creating GitHub Actions in Python
Dockerfile
82
star
6

docker-influxdb-to-s3

Backup and restore InfluxDB databases from S3
Shell
35
star
7

dotfiles

My dotfiles
Shell
22
star
8

website

The code that powers jacobtomlinson.dev
HTML
21
star
9

go-container-action

A template for creating GitHub Actions in Go
Dockerfile
15
star
10

enigma-js

A JavaScript Enigma Machine emulator.
JavaScript
12
star
11

enigma-go

A Go enigma machine emulator
Go
11
star
12

codeigniter-digitalocean

A CodeIgniter library for using the DigitalOcean API
PHP
8
star
13

docker-sqlite-to-s3

Backup and restore sqlite databases from s3
Shell
6
star
14

tube-status

A Python module for accessing tube line status data for the London Underground via Transport for London's open data API.
Python
6
star
15

carte-noire-hugo

A simple Hugo theme for blogging
CSS
6
star
16

docker-serveo

A container to tunnel a local service to the internet
Shell
5
star
17

advent-of-gpu-code-2020

Solutions for Advent of Code 2020 written for the GPU in Python
Jupyter Notebook
5
star
18

asteroid-prospector

A browser based game involving mining asteroids. Part of the 2014 NASA Space Apps Challenge.
5
star
19

gha-lint-yaml

A GitHub Action to lint YAML files
Python
5
star
20

datapoint-js

A JavaScript library for accessing UK weather data via the Met Office's open data API known as Datapoint.
JavaScript
4
star
21

gha-read-helm-chart

Read a Helm chart's Chart.yaml file and expose values as outputs
Go
3
star
22

docker-steam-insurgency

A docker container for running a dedicated Insurgency server
Shell
3
star
23

is-number

A Python library to determine if something is a number. (An example from a blog post series)
Python
3
star
24

gha-get-docker-hub-tags

A GitHub Action to grab the latest tag for an image from Docker Hub
Go
2
star
25

constrainedcoding

A repo to track my video and streaming activities
JavaScript
2
star
26

gha-anaconda-package-version

Get the latest version of an Anaconda package
Go
2
star
27

dask-agent

A process agent for Dask to provide flexibility and control over starting workers/nannies
Python
1
star
28

jacobtomlinson

My profile README repo
Python
1
star
29

helm-repo-example

An example helm repository.
Smarty
1
star
30

gaderian

A tool to gather home utility information
1
star
31

tap-fishing-website

The website for the Tap Fishing game.
CSS
1
star
32

gha-test

Just a test repo. To be deleted.
1
star