MCPcopy Create free account
hub / github.com/kriasoft/graphql-starter-kit / createDeploymentStatus

Function createDeploymentStatus

scripts/github.js:91–136  ·  view source on GitHub ↗

* https://docs.github.com/en/rest/reference/repos#create-a-deployment-status * https://octokit.github.io/rest.js/v18#repos-create-deployment-status

(options = {})

Source from the content-addressed store, hash-verified

89 * https://octokit.github.io/rest.js/v18#repos-create-deployment-status
90 */
91async function createDeploymentStatus(options = {}) {
92 /* eslint-disable @typescript-eslint/no-unused-expressions */
93 options.state === "cancelled" ? "inactive" : options.state;
94 const [owner, repo] = env.GITHUB_REPOSITORY?.split("/") ?? [];
95 const gh = new Octokit({ auth: env.GITHUB_TOKEN });
96
97 let id = options.id;
98
99 if (!options.id && options.ref) {
100 const { data: deployments } = await gh.repos.listDeployments({
101 owner,
102 repo,
103 sha: options.sha,
104 ref: options.ref,
105 task: options.task,
106 environment: options.env,
107 });
108 if (deployments.length === 0) {
109 throw new Error(
110 `Cannot find a deployment by sha: ${options.sha}, ref: ${options.ref}, task: ${options.task}, environment: ${options.env}`,
111 );
112 }
113 if (deployments.length > 1) {
114 throw new Error(
115 `More than one deployment found by sha: ${options.sha}, ref: ${options.ref}, task: ${options.task}, environment: ${options.env}`,
116 );
117 }
118 id = deployments[0].id;
119 }
120
121 const res = await gh.repos.createDeploymentStatus({
122 mediaType: { previews: ["ant-man", "flash"] },
123 owner,
124 repo,
125 deployment_id: id,
126 state: options.state,
127 target_url: options.target_url || options.env_url,
128 log_url: options.log_url,
129 description: options.description,
130 environment: options.env,
131 environment_url: options.env_url || options.target_url,
132 auto_inactive: options.auto_inactive,
133 });
134
135 console.log(res.data);
136}
137
138// Load environment variables (GITHUB_TOKEN, etc.)
139const options = {

Callers 2

createDeploymentFunction · 0.85
github.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected