Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/actions/get-token/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 repositories to target for the access token, separated by commas or newlines. Defaults to the current repository.'
required: false
default: '${{ github.repository }}'

Expand Down Expand Up @@ -60,14 +60,27 @@ 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 response = await fetch(`${TOKEN_EXCHANGE_URL}/api/exchange/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
oidcToken: OIDC_TOKEN,
targetRepo: TARGET_REPOSITORY,
targetRepo: targetRepositories,
requested_permissions: requestedPermissions,
}),
});
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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 ([#354](https://github.com/MetaMask/github-tools/pull/354))

## [1.29.0]

### Added
Expand Down