OneManager
E5
ali
share
Github: https://github.com/qkqpttgf/OneManager-php An index & manager of Onedrive based on serverless. Can be deployed to > Glitch, > Heroku, > Replit, > Vercel, > CFC (Baidu Cloud Function Compute), > FC (Aliyun Function Compute), > SCF (Tencent Serverless Cloud Function), > FG (Huawei cloud Function Graph), > PHP web hosting, > VPS.
Home
/
E5
/
Theme
/
Deploy2VercelByGithub.html
Deploy2VercelByGithub.html
download
<html lang="en-us"> <head> <title>Deploy Project to Vercel</title> <meta name=viewport content="width=device-width,initial-scale=1"> </head> <body> <h1>Deploy to Vercel from Github</h1> <h3>NOT design for OneManager-php (need put it in "app" folder)</h3> <!---(Click <a href="Deploy.html">here</a> to Deploy with zip file.)<br> (Click <a href="DeployFolder.html">here</a> to Deploy with folder.)--> <h4>1. Input Github repo info:</h4> <label>Auth: <input id="Auth" name="Auth" type="text" placeholder="" value="" oninput="this.parentNode.style.color = '';"></label> <label>Repo Name: <input id="Repo" name="Repo" type="text" placeholder="" value="" oninput="this.parentNode.style.color = '';"></label> <label>Branch: <input id="Branch" name="Branch" type="text" placeholder="" value="" oninput="this.parentNode.style.color = '';"></label> <h4>2. <a href="https://vercel.com/account/tokens" target="_blank">Click here to Creat a token</a>, and input:</h4> <label>Token: <input id="VercelToken" name="VercelToken" type="password" placeholder="" value="" oninput="this.parentNode.style.color = '';"></label> <h4>3. Input a name for your project: </h4> <label>Name: <input id="projectname" name="projectname" type="text" placeholder="lower case alphanumeric characters and hyphens" value="" oninput="this.parentNode.style.color = '';"></label> <br> You can overlay an existed project.<br> (You will lost your config, please export the config before overlay.) <h4>4. Click the "Deploy" button</h4> <input id="upload_submit" onclick="preup();" value="Deploy" type="button"> <div id="showerror"></div> <script type="text/javascript"> var errordiv = document.getElementById("showerror"); function preup() { errordiv.innerHTML = ""; var p = 0; document.querySelectorAll("input").forEach(element => { if (element.value=="") { p = 1; element.parentNode.style.color = "red"; errordiv.innerHTML += "<br>Input " + element.name; return; } }); if (p === 0) deploy( document.getElementById("Auth").value, document.getElementById("Repo").value, document.getElementById("Branch").value, document.getElementById("projectname").value, document.getElementById("VercelToken").value, ); else return; } function deploy(Auth, Repo, Branch, projectname, VercelToken) { errordiv.innerHTML += "<br>Deploy POST"; var xhr = new XMLHttpRequest(); var url = "https://api.vercel.com/v13/deployments"; xhr.open("POST", url); xhr.setRequestHeader("Authorization", "Bearer " + VercelToken); xhr.setRequestHeader("Content-Type", "application/json"); var data = { "name": projectname, //"project": appId, "target": "production", "functions": { // change this "api/index.php": { "runtime": "vercel-php@0.4.0" } }, "routes": [ // change this { "src": "/(.*)", "dest": "/api/index.php" } ], "projectSettings": { "framework": null }, "gitSource": { "type": "github", "org": Auth, "repo": Repo, "ref": Branch } } console.log(data); xhr.onload = function(e) { //console.log(xhr.status); console.log(xhr.responseText); var res = JSON.parse(xhr.responseText); //console.log(res); if (xhr.status==200) { errordiv.innerHTML += " ---- done.<br>Deploy POST success!"; getStatus(res.id, res.alias[0], VercelToken); } else { errordiv.innerHTML += "<br>" + xhr.status + "<br>" + res.error.code + "<br>" + res.error.message; } } xhr.send(JSON.stringify(data)); } var x = ""; var min = 0; function getStatus(id, domain, VercelToken) { //console.log(id + " " + domain + " " + VercelToken); x += "."; min++; var xhr = new XMLHttpRequest(); var url = "https://api.vercel.com/v11/now/deployments/" + id; xhr.open("GET", url); xhr.setRequestHeader("Authorization", "Bearer " + VercelToken); xhr.onload = function(e) { if (xhr.status==200) { var deployStat = JSON.parse(xhr.responseText).readyState; if (deployStat=="READY") { x = ""; min = 0; errordiv.innerHTML = "Deploy done.<br>Click <a href=\"http://" + domain + "\" target=\"_blank\">" + domain + "</a> to Install."; } else { errordiv.innerHTML = "Deploy " + deployStat + ", " + min + ".<br>Wait " + x; if (deployStat!=="ERROR") setTimeout(function() { getStatus(id, domain, VercelToken) }, 1000); } } else { console.log(xhr.status); console.log(xhr.responseText); errordiv.innerHTML += "<br>" + xhr.status + "<br>" + xhr.responseText; } } xhr.send(null); } </script> </body> </html>
This file is foot.omf, and valine in it.
2022-07-04 17:15:49 Monday 34.239.147.7 Runningtime:2.528s Mem:426.99 KB