DEV Community

Jirawat Boonkumnerd
Jirawat Boonkumnerd

Posted on

2 1

Auto Request Changes review when the job failed using Github Action

My Workflow

The Github Action is forked from hmarr/auto-approve-action. The action will automatically create a Request Changes pull request review. A use case is to create a request changes review when a workflow job failed.

auto-request-changes-action

The action support 3 input parameters. You can use with jobs..steps[*].with to add the input parameters.

  • github-token: The Github token. By default, it will using ${{ github.token }} to use the repo token.

  • comment-body: The comment body to create a request changes review. The comment-body also support markdown text by Github. The default is Some actions are not successful, please fix it.

  • pull-request-number: (optional) The ID of a pull request to auto-request-changes. By default, this action tries to use the pull_request event payload.

Example use

you can use with if to avoid no pull request event and run only when the job failed.

*for more Github Action Context.

name: Auto request changes
on: pull_request_target

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: ntsd/auto-request-changes-action@v2
        if: ${{ github.event.pull_request && failure() }}
        with:
          comment-body: "The job ran failed please fix it."
Enter fullscreen mode Exit fullscreen mode

You can also use it with auto-approve-action to make it auto approve when the job success.

name: Auto request changes
on: pull_request_target

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: ntsd/auto-request-changes-action@v2
        if: ${{ github.event.pull_request && failure() }}
        with:
          comment-body: "The job ran failed please fix it."
      - uses: hmarr/auto-approve-action@v2
        if: ${{ github.event.pull_request && success() }}
        with:
          github-token: "${{ secrets.GITHUB_TOKEN }}"
Enter fullscreen mode Exit fullscreen mode

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

GitHub logo ntsd / auto-request-changes-action

👍 GitHub Action for automatically request changes GitHub pull requests

Auto Request Changes GitHub Action

This action is a fork from hmarr/auto-approve-action

Name: ntsd/auto-request-changes-action

Automatically request changes GitHub pull requests. The GITHUB_TOKEN secret will default provided as the github-token input for the action to work. otherwise you can add a token to github-token input.

Why?

Because sometimes you want to automate create request changes review. for example, create a request changes review when a lint or testing workflow is failed.

Usage instructions

Create a workflow file (e.g. .github/workflows/auto-request-changes.yml) that contains a step that uses: ntsd/auto-request-changes-action@v2. Here's an example workflow file:

for all github action contexts check https://docs.github.com/en/actions/learn-github-actions/contexts

name: Auto request changes
on: pull_request_target

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: ntsd/auto-request-changes-action@v2
        with:
          github-token: "${{ secrets.GITHUB_TOKEN }}"
          comment-body: "custom comment body"
Enter fullscreen mode Exit fullscreen mode

Combine with an if can only auto-request-changes with only failure workflow

name: Auto
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

Auto Request Changes Action Repo

Auto Request Changes Action Marketplace

Auto Approve Action Repo

Github Action Context

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️