Skip to content

Commit 7084762

Browse files
authored
eng-1829 Genenv now gives invalid production URI (#1102)
1 parent 0a49dd9 commit 7084762

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

packages/database/scripts/createEnv.mts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,22 @@ const makeBranchEnv = async (vercel: Vercel, vercelToken: string) => {
108108
};
109109

110110
const makeProductionEnv = async (vercel: Vercel, vercelToken: string) => {
111-
const result = await vercel.deployments.getDeployments({
111+
const result = await vercel.projects.getProjectDomains({
112112
...baseParams,
113-
projectId: projectIdOrName,
114-
limit: 1,
115-
target: "production",
116-
state: "READY",
113+
idOrName: projectIdOrName,
114+
production: "true",
117115
});
118-
if (result.deployments.length == 0) {
119-
throw new Error("No production deployment found");
116+
const domains = result.domains.filter(
117+
(d) => !d.redirect && d.apexName.indexOf("vercel") < 0,
118+
);
119+
if (domains.length === 0) {
120+
throw new Error("No production domains found");
121+
}
122+
if (domains.length > 1) {
123+
console.log(domains);
124+
throw new Error("Too many production domains found");
120125
}
121-
const url = result.deployments[0]!.url;
126+
const url = domains[0]!.name;
122127
execSync(
123128
`vercel -t ${vercelToken} env pull --environment production .env.production`,
124129
);

0 commit comments

Comments
 (0)