Skip to content

How to Use

Breno A edited this page May 16, 2024 · 2 revisions

How to Use PRP-Preprocessor


Tip

Example repository at TODO

Step 1: Add PRP-Preprocessor to Your Workflow

To use PRP-Preprocessor, you need to include it as a step in your GitHub Actions workflow file. This file is typically located in the .github/workflows directory of your repository and has a .yml or .yaml extension.

Here's an example of how to add PRP-Preprocessor to your workflow:

Simple Example
 - name: Process files
   uses: CIFriends/prp-preprocessor@v1
   env:
     example: 'Hello, World'
All Params
  - name: Run PRP-Preprocessor
    uses: CIFriends/prp-preprocessor@v1
    with:
      rootDir: '.'
      extension: '.prp'
      commitMessage: 'chore: process {_amount_} PRP files'
      userEmail: 'actions@github.com'
      userName: 'CI Friends'
      encoding: 'utf8'
      ignoredVars: ''
      ignoredDirs: ''
      includeSubDirs: 'true'
    env:
      example: 'Hello, World'

Step 2: Add .prp files

PRP-Preprocessor works by replacing variables in files with a .prp.* extension. Here's how you can do it:

  1. Create a new file: In your project directory, create a new file with .prp.* extension. For example, you might create a file named README.prp.md.

  2. Add variables: In your .prp file, you can add variables using the {_ variable _} syntax. For example, you might write {_ example _} in your README.prp.md file to represent the title of your project.

  3. Configure variables: In your GitHub Actions workflow file, you can configure the values of these variables. PRP-Preprocessor will replace the variables in your .prp files with these values when the workflow runs.

Here's an example of a .prp file:

# {_ example _}

This is a sample project.

In this example, {_ example _} is a variables. When the PRP-Preprocessor runs, it will replace these variables with the values you've configured in your workflow file and it creates a file or update existing file removing the .prp, in our example, it would be README.md.

Step 3: Run Your Workflow

Once you've added and configured PRP-Preprocessor, you can run your workflow. If you've set up your workflow to run on certain events (like a push or a pull request), those events will trigger the workflow. You can also manually run the workflow from the Actions tab in your GitHub repository.

PRP-Preprocessor will then replace variables in your files according to your configuration. If there are any issues, you can check the logs for the PRP-Preprocessor step in your workflow run.

That's it! You're now using PRP-Preprocessor to automate variable replacement in your files.