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
369 stars 48 forks source link

Pass over body to REST call #140

Closed pc-ahrens closed 2 years ago

pc-ahrens commented 2 years ago

Hello there,

I've been trying to call the rest api of this to update the visibility of a repository: https://docs.github.com/en/enterprise-server@3.1/rest/reference/repos#update-a-repository

However, every I am not able to pass a body to the route.

- uses: octokit/request-action@v2.1.4
  id: set_private
  with:
    route: PATCH /repos/$ORG/$REPO
    mediaType: application/vnd.github.v3+json
    body: ${{ toJSON(env.REQUEST_BODY) }}
  env:
    GITHUB_TOKEN: ${{ secrets.SITE_ADMIN_PAT }}
    ORG: ${{ fromJSON(steps.issue_body_parser.outputs.payload).Organisation }}
    REPO: ${{ fromJSON(steps.issue_body_parser.outputs.payload).Repository }}
    REQUEST_BODY: |
      '{ "visibility": "private" }'

--> Error: Cannot read property 'map' of undefined

Could you please support me with this? How can I pass over parameters in the body to a REST endpoint?

Best regards Per Ahrens

pc-ahrens commented 2 years ago

Hello again,

adding the private Parameter to "with" solved the issue.

- uses: octokit/request-action@v2.1.4
  id: set_private
  with:
    route: PATCH /repos/$ORG/$REPO
    'private': true
  env:
    GITHUB_TOKEN: ${{ secrets.SITE_ADMIN_PAT }}
    ORG: ${{ fromJSON(steps.issue_body_parser.outputs.payload).Organisation }}
    REPO: ${{ fromJSON(steps.issue_body_parser.outputs.payload).Repository }}

Thanks Per