API call once PR approved

Hi Everyone

I wanna make the workflow acts like this:

  • A user creates a branch and makes a markdown file on it
  • The user creates a pr
  • Admin approves that pr and once approved
    • detects the markdown file added from the branch
    • call an API with that markdown file

I think this workflow could be done by Github Actions.
If anybody has a similar experience, please guide me


On pull_request_review, check if state is approved, grabs the file, and make API call. You got this!

1 Like


You can try to set the workflow like as this.

on: pull_request_review

    . . .
      . . .
      - name: Call API
        if: ${{ github.event.review.state == 'approved' && toJson(github.event.pull_request.requested_reviewers) == '[]' }}
        run: echo "Call API in this step"
      . . .
  • github.event.review.state” returns the latest review state.

  • github.event.pull_request.requested_reviewers” is a json array contains all the requested reviewers who have not approved. If all the requested reviewers have approved, it will return an empty array.