We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我想再github pages 上发布hexo博客.然后自己又很懒,不想每次都再hexo -g; hexo -d等命令.然后又想再issues上写博客,真的很方便.虽然别人可以自由无线评论,但是世界本来就是开放的,这样也无可厚非.
travis 可以又nodejs的环境.所有我就打算用nodejs脚本,根据github的api,获取到issues.然后手动下载到./source/_posts目录下.然后通过一系列命令,发布到gh-pages上.
request(options, function (error, response, body) { if (!error && response.statusCode == 200) { var data = JSON.parse(body); for (iss in data){ if(data[iss].state=='open'){ var article = ''; article+='---\n'; article+='layout: post\n'; article+='tags: '+getTags(data[iss].labels)+'\n'; article+='title: '+data[iss].title+'\n'; article+='date: '+data[iss].created_at+'\n'; article+='---\n\n'; article+=data[iss].body; var fN = getFileName(data[iss].created_at,data[iss].title); var filePath =calFilePath(data[iss].created_at,fN); if(!fsExistsSync(filePath)){ mkdirsSync(filePath); var out = fs.createWriteStream(filePath+fN,{encoding:'utf-8','flag': 'a'}); out.write(article); out.end(); console.log(fN+'----- 已经写入'); }else if(!fsExistsSync(filePath+fN)){ var outs = fs.createWriteStream(filePath+fN,{encoding:'utf-8','flag': 'a'}); outs.write(article); outs.end(); console.log(fN+'----- 已经写入'); }else{ console.log(fN+'----- 已经存在'); } } } } });
其中request的option 如下
var options = { url: 'https://api.github.com/repos/lirawx/mirror/issues', headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36', 'Host':'api.github.com', 'DNT':'1', 'If-None-Match':'W/"074817d16634c58050520f5c85690abf"', 'Upgrade-Insecure-Requests':'1', 'Cache-Control':'0' } };
可以参考,具体请前往https://developer.github.com/v3/repos/
language: node_js node_js: stable # S: Build Lifecycle install: - npm install #before_script: # - npm install -g gulp #node genmd.js script: - node genmd.js - hexo g after_script: - cd ./public - git init - git config user.name "xxxx" - git config user.email "xxxx@xxxx.xxxx" - git add . - git commit -a -m "Update posts" - git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:xxxxx - cd .. - git init - git config user.name "xxxxx" - git config user.email "xxxx@xxxx.com" - git add . - git commit -a -m "Update source" - git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:xxxxx # E: Build LifeCycle branches: only: - xxxxx env: global: - GH_REF: github.com/xxxx/xxxx.git
注意我是一个git仓库,两个不同的分支,一个source分支, 一个master分支,source方源代码,master放gh-pages.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
事故起因
我想再github pages 上发布hexo博客.然后自己又很懒,不想每次都再hexo -g; hexo -d等命令.然后又想再issues上写博客,真的很方便.虽然别人可以自由无线评论,但是世界本来就是开放的,这样也无可厚非.
实现原理
travis 可以又nodejs的环境.所有我就打算用nodejs脚本,根据github的api,获取到issues.然后手动下载到./source/_posts目录下.然后通过一系列命令,发布到gh-pages上.
具体实现
下载issues的主要js代码.
其中request的option 如下
travis ci 配置文件
The text was updated successfully, but these errors were encountered: