Automatically use the GitHub-provided token to allow most users to avoid explicit GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} configuration (#564)

This commit is contained in:
Mateusz Burzyński
2026-01-29 09:35:17 +01:00
committed by GitHub
parent 6af4a7ec08
commit 935fe876b0
6 changed files with 36 additions and 12 deletions
+5 -1
View File
@@ -10,7 +10,9 @@ import { fileExists } from "./utils.ts";
const getOptionalInput = (name: string) => core.getInput(name) || undefined;
(async () => {
let githubToken = process.env.GITHUB_TOKEN;
// to maintain compatibility with workflows created before github-token input was introduced
// it's important to prefer the explicitly set GITHUB_TOKEN over the default token coming from github.token
let githubToken = process.env.GITHUB_TOKEN || core.getInput("github-token");
if (!githubToken) {
core.setFailed("Please add the GITHUB_TOKEN to the changesets action");
@@ -114,6 +116,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
const result = await runPublish({
script: publishScript,
githubToken,
git,
octokit,
createGithubReleases: core.getBooleanInput("createGithubReleases"),
@@ -136,6 +139,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
const octokit = setupOctokit(githubToken);
const { pullRequestNumber } = await runVersion({
script: getOptionalInput("version"),
githubToken,
git,
octokit,
prTitle: getOptionalInput("title"),