gitu_gha-download-images

command module
v0.0.0-...-68c55c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 14 Imported by: 0

README

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: Download Images
        uses: gitu/gha-download-images@v1
        with:
          find: "https://imgur.xx/([^.]+).png"
          target: "$1.png"
      - name: Find and Replace
        uses: jacobtomlinson/gha-find-replace@v2
        with:
          find: "https://imgur.xx/([^.]+).png"
          replace: "$1.png"
Inputs
Input Description
find A string to find and replace in your project files. (A regular expression.)
target The target file, relativ to the file the regex was found in.
include (optional) A glob of files to include. Defaults to **.
exclude (optional) A glob of files to exclude. Defaults to .git/** .
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: gitu/gha-download-images@v1
        with:
          find: "https://imgur.xx/([^.]+).png"
          target: "$1.png"
          include: "justthisdirectory/**"
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: Download Images
        uses: gitu/gha-download-images@v1
        with:
          find: "https://imgur.xx/([^.]+).png"
          target: "$1.png"
          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: gitu/gha-download-images@v1
        with:
          find: "https://imgur.xx/([^.]+).png"
          target: "$1.png"
          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@v2
        with:
          find: "hello"
          replace: "world"
          regex: false
      - name: Push changes
        uses: ad-m/github-push-action@v0.6.0
        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/github-push-action@v0.6.0
        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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL