Skip to content

Commit 9318e2e

Browse files
authored
feat(get-token): support multiple target repositories (#354)
* feat(get-token): support multiple target repositories * chore(get-token): always pass targetRepo as an array * chore(get-token): quote input name in error message * chore(get-token): refine target-repository input description
1 parent 1ba5d9c commit 9318e2e

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎.github/actions/get-token/action.yml‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
description: 'The permissions to request for the access token, in the format of "scope: permission", separated by newlines.'
1010
required: true
1111
target-repository:
12-
description: 'The repository to target for the access token. Defaults to the current repository.'
12+
description: 'The repositories to target for the access token, separated by commas or newlines. Defaults to the current repository.'
1313
required: false
1414
default: '${{ github.repository }}'
1515

@@ -60,14 +60,27 @@ runs:
6060
.map(line => line.split(':').map(part => part.trim()))
6161
);
6262
63+
const targetRepositories = [
64+
...new Set(
65+
TARGET_REPOSITORY
66+
.split(/[\n,]/)
67+
.map(repo => repo.trim())
68+
.filter(Boolean)
69+
),
70+
];
71+
72+
if (targetRepositories.length === 0) {
73+
return core.setFailed('"target-repository" must include at least one repository.');
74+
}
75+
6376
const response = await fetch(`${TOKEN_EXCHANGE_URL}/api/exchange/token`, {
6477
method: 'POST',
6578
headers: {
6679
'Content-Type': 'application/json'
6780
},
6881
body: JSON.stringify({
6982
oidcToken: OIDC_TOKEN,
70-
targetRepo: TARGET_REPOSITORY,
83+
targetRepo: targetRepositories,
7184
requested_permissions: requestedPermissions,
7285
}),
7386
});

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Support multiple comma- or newline-separated repositories in the `get-token` action's `target-repository` input ([#354](https://github.com/MetaMask/github-tools/pull/354))
13+
1014
## [1.29.0]
1115

1216
### Added

0 commit comments

Comments
 (0)