Skip to content

Commit 3d66daa

Browse files
committed
add repository in package.json for oicd if it doesnt exist
1 parent 9b3f8a6 commit 3d66daa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/publish.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ export async function publish(args) {
129129

130130
processPackageJson(packageDirectory, packageJson, { logger });
131131

132+
// For OIDC: ensure repository field exists (required for provenance)
133+
if (args.useOidc && repoUrl) {
134+
const repoMatch = repoUrl.match(/github\.com[:/]([^/]+)\/([^/.]+)/);
135+
if (repoMatch && !packageJson.repository?.url) {
136+
const repoUrlNormalized = `https://github.com/${repoMatch[1]}/${repoMatch[2]}.git`;
137+
logger.info(`Adding repository field for OIDC provenance: ${repoUrlNormalized}`);
138+
packageJson.repository = {
139+
type: 'git',
140+
url: repoUrlNormalized
141+
};
142+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
143+
}
144+
}
145+
132146
if (webhook) {
133147
const commitMessageOneLiner = commitMessage?.trim().replaceAll("\n", " ");
134148
const commitUrl = event_data?.compare || `${repoUrl}/commit/${shortSha}`;

0 commit comments

Comments
 (0)