2022-11-02 04:05:12 +00:00
|
|
|
import { promisify } from "util";
|
|
|
|
|
|
|
|
import { publish } from "gh-pages";
|
2022-09-09 00:16:13 +00:00
|
|
|
|
|
|
|
/* fix for "Unhandled promise rejections" */
|
2022-11-02 04:05:12 +00:00
|
|
|
process.on("unhandledRejection", (err) => {
|
|
|
|
throw err;
|
|
|
|
});
|
2022-09-09 00:16:13 +00:00
|
|
|
|
2022-11-02 04:05:12 +00:00
|
|
|
const ghpublish = promisify(publish);
|
2022-09-09 16:04:44 +00:00
|
|
|
|
2022-11-02 04:05:12 +00:00
|
|
|
const Args = process.argv.slice(2);
|
|
|
|
const USE_HTTPS = Args[0] && Args[0].toUpperCase() === "HTTPS";
|
2022-09-09 00:16:13 +00:00
|
|
|
|
2022-11-02 04:05:12 +00:00
|
|
|
const branch = "gh-pages";
|
|
|
|
const org = "waku-org";
|
|
|
|
const repo = "js-waku";
|
2022-09-09 00:16:13 +00:00
|
|
|
/* use SSH auth by default */
|
|
|
|
let repoUrl = USE_HTTPS
|
|
|
|
? `https://github.com/${org}/${repo}.git`
|
2022-11-02 04:05:12 +00:00
|
|
|
: `git@github.com:${org}/${repo}.git`;
|
2022-09-09 00:16:13 +00:00
|
|
|
|
|
|
|
/* alternative auth using GitHub user and API token */
|
|
|
|
if (typeof process.env.GH_USER !== "undefined") {
|
2022-11-02 04:05:12 +00:00
|
|
|
repoUrl =
|
|
|
|
"https://" +
|
|
|
|
process.env.GH_USER +
|
|
|
|
":" +
|
|
|
|
process.env.GH_TOKEN +
|
|
|
|
"@" +
|
|
|
|
`github.com/${org}/${repo}.git`;
|
2022-09-09 00:16:13 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 04:05:12 +00:00
|
|
|
const main = async (url, branch) => {
|
|
|
|
console.log(`Pushing to: ${url}`);
|
|
|
|
console.log(`On branch: ${branch}`);
|
|
|
|
await ghpublish("docs", {
|
2022-09-09 00:16:13 +00:00
|
|
|
repo: url,
|
|
|
|
branch: branch,
|
|
|
|
dotfiles: true,
|
2023-08-16 14:48:13 +00:00
|
|
|
silent: false
|
2022-11-02 04:05:12 +00:00
|
|
|
});
|
|
|
|
};
|
2022-09-09 00:16:13 +00:00
|
|
|
|
2023-08-16 14:48:13 +00:00
|
|
|
void main(repoUrl, branch);
|