octokit / request-action

A GitHub Action to send arbitrary requests to GitHub's REST API

Home Page:https://github.com/marketplace/actions/GitHub-API-Request

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pass over body to REST call

pc-ahrens opened this issue · comments

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

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