octokit / request-action

A GitHub Action to send arbitrary requests to GitHub's REST API
https://github.com/marketplace/actions/GitHub-API-Request
MIT License
382 stars 47 forks source link

[DOCS]: Clarify how to set body inputs #294

Open miguel-vila opened 9 months ago

miguel-vila commented 9 months ago

Describe the need

I had to look into the code in order to do pass input to a workflow dispatch invocation. And I'm not sure if I did it the way that's intended. The inputs section in the readme wasn't clear enough to me. Could we clarify that?

This is the invocation I ended up with:

- uses: octokit/request-action@v2.x
  if: contains(github.event.pull_request.labels.*.name, 'open-ar-pr')
  with:
    route: POST /repos/platform-common/api-registry/actions/workflows/bump-arlib-version.yml/dispatches
    mediaType: application/vnd.github.v3+json
    ref: main
  env:
    GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
    INPUT_INPUTS: |
      {
        "pr-number": "${{ github.event.pull_request.number }}",
        "version": "${{ steps.get-version.outputs.version }}"
      }

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 9 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

gr2m commented 9 months ago

I'd do

  with:
    route: POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches
    owner: platform-common
    repo: repo
    workflow_id: bump-arlib-version.yml
    ref: main
    inputs: |
        pr-number: "${{ github.event.pull_request.number }}"
        version: "${{ steps.get-version.outputs.version }}"

You can see examples of how to pass object body parameters in the advanced README example. The | is significant in order for the value to be parsed as an object

miguel-vila commented 9 months ago

@gr2m thank you, I think I tried that, but the format wasn't the correct. I was probably trying a JSON.