Skip to content

ddalpange/find-and-replace-pull-request-body

 
 

Repository files navigation

find-and-replace-pull-request-body

This action replaces the workflow related action Pull Request body.



Usage

Replacing the entire PR body (continuous)

      - name: Replace Pull Request Body
        uses: ivangabriele/find-and-replace-pull-request-body@v1.1.5
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          body: |
            # A New PR Body Title

            With a new body description.

Replacing a specific part of the PR body using a string (one time)

Let's say you have a PR body like this:

# Preview URL

_Waiting for deployment..._
      - name: Replace Pull Request Body
        uses: ivangabriele/find-and-replace-pull-request-body@v1.1.5
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          find: '_Waiting for deployment..._'
          replace: 'https://example.com/my-preview'

will replace the find string with the replace string and update the PR body to become:

# Preview URL

https://example.com/my-preview

Replacing a specific part of the PR body using an HTML Comment Tag (continuous)

Let's say you have a PR body like this:

# Preview URL

<!-- AUTOFILLED_PREVIEW_URL -->
_Waiting for deployment..._
<!-- AUTOFILLED_PREVIEW_URL -->
      - name: Replace Pull Request Body
        uses: ivangabriele/find-and-replace-pull-request-body@v1.1.5
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          find: 'AUTOFILLED_PREVIEW_URL'
          isHtmlCommentTag: true
          replace: 'https://example.com/my-preview'

will replace what's between the find HTML Comment Tags with the replace string and update the PR body to become:

# Preview URL

<!-- AUTOFILLED_PREVIEW_URL -->
https://example.com/my-preview
<!-- AUTOFILLED_PREVIEW_URL -->

Running against different workflow triggers

If running the workflow in response to a pull_request event the action will update the associated pull request.

The action can be configured to update a manually specified pull request instead, by providing the prNumber. This way it can be ran in response to a deployment_status event, or a manual workflow_dispatch trigger.

      - name: Replace Pull Request Body
        uses: ivangabriele/find-and-replace-pull-request-body@v1.1.5
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          prNumber: ${{ inputs.pr }}

About

Github Action replacing workflow related Pull Request body.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%