diff --git a/.github/actions/vercel/index.mjs b/.github/actions/vercel/index.mjs index 810aa3037f2d..92f387a0fe3f 100644 --- a/.github/actions/vercel/index.mjs +++ b/.github/actions/vercel/index.mjs @@ -8,11 +8,15 @@ import { updateProjectEnv } from "./commands/update-env.mjs"; // All inputs retrieved via `getInput` are defined in `action.yml`, and should be kept in sync -const client = new Client(getRequiredInput("vercel_token")); - -const command = getRequiredInput("command"); +const token = getRequiredInput("vercel_token"); const team = getRequiredInput("vercel_team_name"); const project = getRequiredInput("vercel_project_name"); +const command = getRequiredInput("command"); +const commit = getInput("release_commit"); +const version = getInput("release_version"); +const target = getInput("target"); + +const client = new Client(token); switch (command) { case "deploy": @@ -31,18 +35,13 @@ switch (command) { * @param {string} project */ async function deploy(client, team, project) { - const target = getRequiredInput("target"); switch (target) { case "production": { - const commit = getRequiredInput("release_commit"); - const version = getRequiredInput("release_version"); await deployToProduction(client, { team, project, commit, version }); break; } case "preview": { - const commit = getRequiredInput("release_commit"); - const version = getInput("release_version"); await deployToPreview(client, { team, project, commit, version }); break; } @@ -59,9 +58,6 @@ async function deploy(client, team, project) { * @param {string} project */ async function updateEnv(client, team, project) { - const commit = getInput("release_commit"); - const version = getInput("release_version"); - if (!commit && !version) { throw new Error( `one of "release_commit", "release_version" must be specified`,