Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle repositories input with spaces between repositories #106

Open
niodice opened this issue Feb 27, 2024 · 2 comments
Open

Handle repositories input with spaces between repositories #106

niodice opened this issue Feb 27, 2024 · 2 comments

Comments

@niodice
Copy link

niodice commented Feb 27, 2024

This action could handle a little more flexibility in the repositories input. A common mistake is to provide repositories: foo, bar instead of repositories: foo,bar if a token is needed for > 1 repository.

For example:

    - name: Generate Github Actions App token
      id: generate-token
      uses: actions/create-github-app-token@v1
      with:
        app-id: ${{ env.GH_APP_APP_ID }}
        private-key: ${{ env.GH_APP_PRIVATE_KEY }}
        repositories: foo, bar

Fails to get a token because the body in the HTTP request to GH will look like this:

body: '{"repositories":["foo"," bar"]}',

I think trimming the repos, something like repos = repos.map(r => r.trim()), would catch this and make for a more intuitive API

@gr2m
Copy link
Contributor

gr2m commented Feb 27, 2024

Yes, we should definitely do that. Pull request welcome! Please add a test or update one of the existing ones 🙏

@krokofant
Copy link

Should trailing commas be trimmed as well? Seems these lines needs to be changed

repo: parsedRepositoryNames.split(",")[0],

repositoryNames: parsedRepositoryNames.split(","),

For just spaces

'a, b,c , d'.split(/\s*,\s*/)

With trailing commas:

'a, b,c , d,'.replace(/,\s*$/,'').split(/\s*,\s*/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants