Skip to content

Commit 8884d4e

Browse files
committed
feat(cli): append some context to GITHUB_OUTPUT
1 parent c129933 commit 8884d4e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/cli/environments.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ declare global {
3030
GITHUB_JOB: string;
3131
// A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run. For example, 3.
3232
GITHUB_RUN_ATTEMPT: string;
33+
// A file to set action outputs
34+
GITHUB_OUTPUT: string;
3335
}
3436
}
3537
}

packages/cli/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ const main = defineCommand({
159159
GITHUB_RUN_ID,
160160
GITHUB_RUN_ATTEMPT,
161161
GITHUB_ACTOR_ID,
162+
GITHUB_OUTPUT,
162163
} = process.env;
163164

164165
const [owner, repo] = GITHUB_REPOSITORY.split("/");
@@ -188,6 +189,7 @@ const main = defineCommand({
188189
}
189190

190191
const { sha } = await checkResponse.json();
192+
const formattedSha = isCompact ? abbreviateCommitHash(sha) : sha;
191193

192194
const deps: Map<string, string> = new Map(); // pkg.pr.new versions of the package
193195
const realDeps: Map<string, string> | null = isPeerDepsEnabled
@@ -221,7 +223,6 @@ const main = defineCommand({
221223
await verifyCompactMode(pJson.name);
222224
}
223225

224-
const formattedSha = isCompact ? abbreviateCommitHash(sha) : sha;
225226
const depUrl = new URL(
226227
`/${owner}/${repo}/${pJson.name}@${formattedSha}`,
227228
apiUrl,
@@ -533,6 +534,13 @@ const main = defineCommand({
533534
await fs.writeFile(jsonFilePath, output);
534535
console.warn(`metadata written to ${jsonFilePath}`);
535536
}
537+
538+
await fs.appendFile(GITHUB_OUTPUT, `tag=${formattedSha}\n`, "utf8");
539+
await fs.appendFile(
540+
GITHUB_OUTPUT,
541+
`packages=${outputMetadata.packages.map((pkg) => pkg.url).join(" ")}\n`,
542+
"utf8",
543+
);
536544
},
537545
};
538546
},

0 commit comments

Comments
 (0)