actions / create-github-app-token

GitHub Action for creating a GitHub App Installation Access Token
https://github.com/marketplace/actions/create-github-app-token
MIT License
344 stars 47 forks source link

[FEAT]: Support overriding github api url #77

Closed gr2m closed 7 months ago

gr2m commented 10 months ago

originally posted by @harshtrivedi134 at https://github.com/octokit/octokit.js/issues/2569

Describe the need

Reference from discussion I was creating an access token for a github app installed in a different organization and repository. I learned about https://github.com/actions/create-github-app-token#create-a-token-for-all-repositories-in-another-owners-installation.

Similar to the baseUrl option in Octokit constructor, it would be great if we could specify the github API url as an input to this action

      - uses: actions/create-github-app-token@v1
        id: get-access-token
        with:
          app-id: APP_ID
          private-key: PRIVATE_KEY
          base-url: https://slack-github.com/api/

I tried creating an access token for my github app installed in a different organization by specifying the owner and repository using the following:

      - uses: actions/create-github-app-token@v1
        id: get-access-token
        with:
          app-id: APP_ID
          private-key: PRIVATE_KEY
          owner: "owner"
          repositories: |
            owner/repo_name

However, the default github API hostname/url is set to api.github.com and we cannot change it to a custom hosted github installation.

Code of Conduct

gr2m commented 10 months ago

We pretty much implement the same thing as tibdex/github-app-token does here: https://github.com/tibdex/github-app-token/blob/3eb77c7243b85c65e84acfa93fdbac02fb6bd532/action.yml#L8C1-L10C35

smockle commented 10 months ago

@gr2m Isn’t this already supported? The action reads an environment variable named GITHUB_API_URL: https://github.com/actions/create-github-app-token/blob/9769eb4076a1785cd28c7f83b17b1e855fb092b8/lib/request.js#L4C30-L4C30

gr2m commented 10 months ago

I think @harshtrivedi134 is asking to pass a custom GitHub API URL which is different from the one configured in the Action, in order to access an organization on a different server?

harshtrivedi134 commented 10 months ago

I think @harshtrivedi134 is asking to pass a custom GitHub API URL which is different from the one configured in the Action, in order to access an organization on a different server?

That's correct. In my case, I am trying to run the workflow in a github.com repo and the Github app is installed in an organization in Github Enterprise.

cliffchapmanrbx commented 8 months ago

This is a hard blocker from our team using this action. A long time ago I filed a ticket for this in tibdex's version of the action. Support is nearly trivial to add and this would allow us to migrate our use to this action.

gr2m commented 8 months ago

I started a PR here, can y'all have a look? https://github.com/actions/create-github-app-token/pull/88. Tests still need fixing and I'll add a test specific to the new option, but otherwise this should be good to go

kieran-lowe commented 7 months ago

@gr2m had a look and left some feedback testing this in the PR along with someone else!

create-app-token-action-releaser[bot] commented 7 months ago

:tada: This issue has been resolved in version 1.7.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: