发布文件到 Github

admin2021-01-15  285

// ${name: publishGithub}
// ${title: 发布文件到 Github}
  
import crypt
import console;
import web.rest.jsonClient
   
var http = web.rest.jsonClient();
var repos = http.api("https://api.github.com/repos/");
http.addHeaders = {
    ["Authorization"] = "token your-token-value"
}
  
var info = repos["用户名"]["仓库名"]["路径"].contents.get();
http.beforeStringifyRequestParameters = function(params){   
    if(info[["sha"]]) params.sha = info[["sha"]];
    params.message = (info[["sha"]] ? "Updata ":"Add ") + "some file!"
    return params; 
}
  
var ret = repos["用户名"]["仓库名"]["路径"].contents.put({
    content = crypt.bin.encodeBase64( string.load(文件) )
})
  
console.pause(true);
转载请注明原文地址: http://aardio.net/read-128.html
最新回复(0)