-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathgetSepoliaDeploymentUrl.mjs
More file actions
49 lines (39 loc) · 1.33 KB
/
getSepoliaDeploymentUrl.mjs
File metadata and controls
49 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Vercel } from "@vercel/sdk";
/**
* @description The script in this file is used by .github/workflows/e2e.yml
* to provide the sepolia deployment url
*/
/**
* @description Gets the latest Sepolia deployment url
* @returns {Promise<string>}
*/
async function main() {
const token = process.env.VERCEL_TOKEN;
const githubSha = process.env.GITHUB_SHA;
try {
const vercel = new Vercel({
bearerToken: token,
});
const teamsResult = await vercel.teams.getTeams({
limit: 20,
});
const cartesiTeamId = teamsResult.teams.find(
(team) => team.slug === "cartesi",
)?.id;
const deploymentsResult = await vercel.deployments.getDeployments({
app: "rollups-explorer-sepolia",
teamId: cartesiTeamId,
sha: githubSha,
});
const [latestDeployment] = deploymentsResult.deployments;
// The Property is called 'url', but currently it lacks an important part: the protocol.
return latestDeployment.url.includes("https://")
? latestDeployment.url
: `https://${latestDeployment.url}`;
} catch (error) {
console.error("Error while retrieving deployment data:", error);
process.exit(1);
}
}
const url = await main();
process.stdout.write(url);