Skip to content

Commit

Permalink
🐛 Don't publish private sites (fixed upptime/upptime#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Dec 7, 2020
1 parent 6d6b3e2 commit f7cd5c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/interfaces.ts
Expand Up @@ -29,6 +29,7 @@ export interface UpptimeConfig {
introTitle?: string;
introMessage?: string;
navbar?: { title: string; url: string }[];
publish?: boolean;
};
skipDescriptionUpdate?: boolean;
skipTopicsUpdate?: boolean;
Expand Down
16 changes: 16 additions & 0 deletions src/site.ts
@@ -1,11 +1,27 @@
import { cd, cp, exec, mkdir } from "shelljs";
import { getConfig } from "./helpers/config";
import { getOctokit } from "./helpers/github";
import { shouldContinue } from "./helpers/init-check";

export const generateSite = async () => {
if (!(await shouldContinue())) return;
let [owner, repo] = (process.env.GITHUB_REPOSITORY || "").split("/");
const config = await getConfig();
const octokit = await getOctokit();
const repoDetails = await octokit.repos.get({ owner, repo });
const siteDir = "site";
mkdir(siteDir);
cd(siteDir);
/**
* If this is a private repository, we don't publish a status page
* by default, but can be overwritten with `publish: true`
*/
if (repoDetails.data.private && !(config["status-website"] || {}).publish) {
mkdir("-p", "status-page/__sapper__/export");
exec("echo 404 > status-page/__sapper__/export/index.html");
cd("../..");
return;
}
exec("npm init -y");
exec("npm i @upptime/status-page");
cp("-r", "node_modules/@upptime/status-page/*", ".");
Expand Down

0 comments on commit f7cd5c6

Please sign in to comment.