removed github features

pull/28/head
jehfkemsy 3 years ago
parent 364c7ca09a
commit b49d9d591a

9410
index.js

File diff suppressed because one or more lines are too long

@ -1,5 +1,5 @@
import { getInput, setOutput, setFailed } from "@actions/core"; import { getInput, setOutput, setFailed } from "@actions/core";
import { context, getOctokit } from "@actions/github"; // import { context, getOctokit } from "@actions/github";
import shellac from "shellac"; import shellac from "shellac";
import { fetch } from "undici"; import { fetch } from "undici";
@ -52,10 +52,10 @@ try {
const accountId = getInput("accountId", { required: true }); const accountId = getInput("accountId", { required: true });
const projectName = getInput("projectName", { required: true }); const projectName = getInput("projectName", { required: true });
const directory = getInput("directory", { required: true }); const directory = getInput("directory", { required: true });
const gitHubToken = getInput("gitHubToken", { required: true }); // const gitHubToken = getInput("gitHubToken", { required: true });
const branch = getInput("branch", { required: false }); const branch = getInput("branch", { required: false });
const octokit = getOctokit(gitHubToken); // const octokit = getOctokit(gitHubToken);
const createPagesDeployment = async () => { const createPagesDeployment = async () => {
// TODO: Replace this with an API call to wrangler so we can get back a full deployment response object // TODO: Replace this with an API call to wrangler so we can get back a full deployment response object
@ -79,48 +79,48 @@ try {
return deployment; return deployment;
}; };
const createGitHubDeployment = async () => { // const createGitHubDeployment = async () => {
const deployment = await octokit.rest.repos.createDeployment({ // const deployment = await octokit.rest.repos.createDeployment({
owner: context.repo.owner, // owner: context.repo.owner,
repo: context.repo.repo, // repo: context.repo.repo,
ref: context.ref, // ref: context.ref,
auto_merge: false, // auto_merge: false,
description: "Cloudflare Pages", // description: "Cloudflare Pages",
required_contexts: [], // required_contexts: [],
}); // });
if (deployment.status === 201) { // if (deployment.status === 201) {
return deployment.data; // return deployment.data;
} // }
}; // };
const createGitHubDeploymentStatus = async ({ // const createGitHubDeploymentStatus = async ({
id, // id,
url, // url,
environmentName, // environmentName,
productionEnvironment, // productionEnvironment,
}: { // }: {
id: number; // id: number;
url: string; // url: string;
environmentName: string; // environmentName: string;
productionEnvironment: boolean; // productionEnvironment: boolean;
}) => { // }) => {
await octokit.rest.repos.createDeploymentStatus({ // await octokit.rest.repos.createDeploymentStatus({
owner: context.repo.owner, // owner: context.repo.owner,
repo: context.repo.repo, // repo: context.repo.repo,
deployment_id: id, // deployment_id: id,
// @ts-ignore // // @ts-ignore
environment: environmentName, // environment: environmentName,
environment_url: url, // environment_url: url,
production_environment: productionEnvironment, // production_environment: productionEnvironment,
log_url: `https://dash.cloudflare.com/${accountId}/pages/view/${projectName}/${id}`, // log_url: `https://dash.cloudflare.com/${accountId}/pages/view/${projectName}/${id}`,
description: "Cloudflare Pages", // description: "Cloudflare Pages",
state: "success", // state: "success",
}); // });
}; // };
(async () => { (async () => {
const gitHubDeployment = await createGitHubDeployment(); // const gitHubDeployment = await createGitHubDeployment();
const pagesDeployment = await createPagesDeployment(); const pagesDeployment = await createPagesDeployment();
@ -128,20 +128,20 @@ try {
setOutput("url", pagesDeployment.url); setOutput("url", pagesDeployment.url);
setOutput("environment", pagesDeployment.environment); setOutput("environment", pagesDeployment.environment);
const url = new URL(pagesDeployment.url); // const url = new URL(pagesDeployment.url);
const productionEnvironment = pagesDeployment.environment === "production"; // const productionEnvironment = pagesDeployment.environment === "production";
const environmentName = productionEnvironment // const environmentName = productionEnvironment
? "Production" // ? "Production"
: `Preview (${url.host.split(".")[0]})`; // : `Preview (${url.host.split(".")[0]})`;
if (gitHubDeployment) { // if (gitHubDeployment) {
await createGitHubDeploymentStatus({ // await createGitHubDeploymentStatus({
id: gitHubDeployment.id, // id: gitHubDeployment.id,
url: pagesDeployment.url, // url: pagesDeployment.url,
environmentName, // environmentName,
productionEnvironment, // productionEnvironment,
}); // });
} // }
})(); })();
} catch (thrown) { } catch (thrown) {
setFailed(thrown.message); setFailed(thrown.message);

Loading…
Cancel
Save