From f692c530bb0fd019a97c97b42aaa629b8a059740 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Tue, 1 Dec 2026 15:15:58 +0100 Subject: [PATCH 1/4] feat(get-token): support multiple target repositories --- .github/actions/get-token/action.yml | 21 +++++++++++++++++++-- CHANGELOG.md | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/actions/get-token/action.yml b/.github/actions/get-token/action.yml index 51b0a3f0..7dc76057 100644 --- a/.github/actions/get-token/action.yml +++ b/.github/actions/get-token/action.yml @@ -9,7 +9,7 @@ inputs: description: 'The permissions to request for the access token, in the format of "scope: permission", separated by newlines.' required: true target-repository: - description: 'The repository to target for the access token. Defaults to the current repository.' + description: 'The repository (or comma/newline-separated repositories) to target for the access token. Defaults to the current repository.' required: false default: '${{ github.repository }}' @@ -60,6 +60,23 @@ runs: .map(line => line.split(':').map(part => part.trim())) ); + const targetRepositories = [ + ...new Set( + TARGET_REPOSITORY + .split(/[\n,]/) + .map(repo => repo.trim()) + .filter(Boolean) + ), + ]; + + if (targetRepositories.length === 0) { + return core.setFailed('target-repository must include at least one repository.'); + } + + const targetRepo = targetRepositories.length === 1 + ? targetRepositories[0] + : targetRepositories; + const response = await fetch(`${TOKEN_EXCHANGE_URL}/api/exchange/token`, { method: 'POST', headers: { @@ -67,7 +84,7 @@ runs: }, body: JSON.stringify({ oidcToken: OIDC_TOKEN, - targetRepo: TARGET_REPOSITORY, + targetRepo, requested_permissions: requestedPermissions, }), }); diff --git a/CHANGELOG.md b/CHANGELOG.md index 4186e02b..406a4cb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Support multiple comma- or newline-separated repositories in the `get-token` action's `target-repository` input + - Single-repository calls continue sending a string `targetRepo`, while multi-repository calls send an array for single-owner policies. + ## [1.29.0] ### Added From 39200f2867842fde732630650ea860fb7fb6aeff Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Tue, 1 Dec 2026 15:44:57 +0100 Subject: [PATCH 2/4] chore(get-token): always pass targetRepo as an array --- .github/actions/get-token/action.yml | 6 +----- CHANGELOG.md | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/actions/get-token/action.yml b/.github/actions/get-token/action.yml index 7dc76057..3e5340b3 100644 --- a/.github/actions/get-token/action.yml +++ b/.github/actions/get-token/action.yml @@ -73,10 +73,6 @@ runs: return core.setFailed('target-repository must include at least one repository.'); } - const targetRepo = targetRepositories.length === 1 - ? targetRepositories[0] - : targetRepositories; - const response = await fetch(`${TOKEN_EXCHANGE_URL}/api/exchange/token`, { method: 'POST', headers: { @@ -84,7 +80,7 @@ runs: }, body: JSON.stringify({ oidcToken: OIDC_TOKEN, - targetRepo, + targetRepo: targetRepositories, requested_permissions: requestedPermissions, }), }); diff --git a/CHANGELOG.md b/CHANGELOG.md index 406a4cb1..bdf3a437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Support multiple comma- or newline-separated repositories in the `get-token` action's `target-repository` input - - Single-repository calls continue sending a string `targetRepo`, while multi-repository calls send an array for single-owner policies. +- 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)) ## [1.29.0] From 6495665f3d54b6e43170211f6277d8786001a31a Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Wed, 2 Dec 2026 09:44:18 +0100 Subject: [PATCH 3/4] chore(get-token): quote input name in error message --- .github/actions/get-token/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/get-token/action.yml b/.github/actions/get-token/action.yml index 3e5340b3..5bd349e5 100644 --- a/.github/actions/get-token/action.yml +++ b/.github/actions/get-token/action.yml @@ -70,7 +70,7 @@ runs: ]; if (targetRepositories.length === 0) { - return core.setFailed('target-repository must include at least one repository.'); + return core.setFailed('"target-repository" must include at least one repository.'); } const response = await fetch(`${TOKEN_EXCHANGE_URL}/api/exchange/token`, { From b877f9f15f8ec505bd943d04bf1dca89cfbdb84b Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Wed, 2 Dec 2026 09:45:31 +0100 Subject: [PATCH 4/4] chore(get-token): refine target-repository input description --- .github/actions/get-token/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/get-token/action.yml b/.github/actions/get-token/action.yml index 5bd349e5..ce46af03 100644 --- a/.github/actions/get-token/action.yml +++ b/.github/actions/get-token/action.yml @@ -9,7 +9,7 @@ inputs: description: 'The permissions to request for the access token, in the format of "scope: permission", separated by newlines.' required: true target-repository: - description: 'The repository (or comma/newline-separated repositories) to target for the access token. Defaults to the current repository.' + description: 'The repositories to target for the access token, separated by commas or newlines. Defaults to the current repository.' required: false default: '${{ github.repository }}'