-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate-deployment.js
More file actions
24 lines (22 loc) · 811 Bytes
/
create-deployment.js
File metadata and controls
24 lines (22 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// @ts-check
/**
* @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments
*/
export default async ({ github, context, core }) => {
const githubBranch = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME;
const productionEnvironment = githubBranch === 'main';
const environmentName = `[site] (${productionEnvironment ? 'Production' : githubBranch})`;
const deployment = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: githubBranch || context.ref,
auto_merge: false,
description: 'Site Cloudflare Pages',
required_contexts: [],
environment: environmentName,
production_environment: productionEnvironment,
});
if (deployment.status === 201) {
core.setOutput('deployment-id', deployment.data.id);
}
};