feat: allow repositories input to be comma or newline-separated (#169)
Resolves https://github.com/actions/create-github-app-token/issues/106 - Fixes the parsing to cope with whitespace in the input string. - Allows the input to be comma or newline-separated. (I've done this for all array-type inputs in my own actions, but I'm happy to remove this if you only want to support comma-separated.) - Added tests for parsing comma and newline-separated inputs.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { test } from "./main.js";
|
||||
|
||||
// Verify `main` successfully obtains a token when the `owner` and `repositories` inputs are set (and the latter is a list of repos).
|
||||
await test(() => {
|
||||
process.env.INPUT_OWNER = process.env.GITHUB_REPOSITORY_OWNER;
|
||||
const currentRepoName = process.env.GITHUB_REPOSITORY.split("/")[1];
|
||||
// Intentional unnecessary whitespace to test parsing to array
|
||||
process.env.INPUT_REPOSITORIES = `\n ${currentRepoName}\ntoolkit \n\n checkout \n`;
|
||||
});
|
||||
@@ -4,5 +4,6 @@ import { test } from "./main.js";
|
||||
await test(() => {
|
||||
process.env.INPUT_OWNER = process.env.GITHUB_REPOSITORY_OWNER;
|
||||
const currentRepoName = process.env.GITHUB_REPOSITORY.split("/")[1];
|
||||
process.env.INPUT_REPOSITORIES = `${currentRepoName},toolkit`;
|
||||
// Intentional unnecessary whitespace to test parsing to array
|
||||
process.env.INPUT_REPOSITORIES = ` ${currentRepoName}, toolkit ,checkout`;
|
||||
});
|
||||
|
||||
@@ -134,6 +134,25 @@ Generated by [AVA](https://avajs.dev).
|
||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
::save-state name=expiresAt::2016-07-11T22:14:10Z`
|
||||
|
||||
## main-token-get-owner-set-repo-set-to-many-newline.test.js
|
||||
|
||||
> stderr
|
||||
|
||||
''
|
||||
|
||||
> stdout
|
||||
|
||||
`owner and repositories set, creating token for repositories "create-github-app-token,toolkit,checkout" owned by "actions"␊
|
||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
␊
|
||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
␊
|
||||
::set-output name=installation-id::123456␊
|
||||
␊
|
||||
::set-output name=app-slug::github-actions␊
|
||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
::save-state name=expiresAt::2016-07-11T22:14:10Z`
|
||||
|
||||
## main-token-get-owner-set-repo-set-to-many.test.js
|
||||
|
||||
> stderr
|
||||
@@ -142,7 +161,7 @@ Generated by [AVA](https://avajs.dev).
|
||||
|
||||
> stdout
|
||||
|
||||
`owner and repositories set, creating token for repositories "create-github-app-token,toolkit" owned by "actions"␊
|
||||
`owner and repositories set, creating token for repositories "create-github-app-token,toolkit,checkout" owned by "actions"␊
|
||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
␊
|
||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user