Skip to content

Commit

Permalink
feat(docs): 增加文档 GH-Pages 发布脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Sep 11, 2018
1 parent 1a03c47 commit cb03e07
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: 2
jobs:
front_end:
branches:
ignore:
- gh-pages
working_directory: ~/plus
docker:
- image: circleci/node:10
Expand All @@ -16,6 +19,9 @@ jobs:
name: "Run Production"
command: "npm run production"
back_end:
branches:
ignore:
- gh-pages
working_directory: ~/plus
docker:
- image: circleci/php:7.1-jessie-node-browsers
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ sudo: false

language: php

branches:
except:
- gh-pages

matrix:
fast_finish: true
include:
Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
2 changes: 1 addition & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
title: 'Plus (ThinkSNS+)',
description: 'Plus (ThinkSNS+) 是使用 Laravel 框架开发;一个功能强大、易于开发和动态拓展的社交系统。',
head: require('./head'),
dest: '.vuepress/dist',
dest: 'docs/.vuepress/dist',
ga: undefined,
serviceWorker: false,
locales: require('./locales'),
Expand Down
30 changes: 30 additions & 0 deletions scripts/publish-docs-gh-pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -euo pipefail

GIT_DIR="/tmp/plus-publish-gh-pages"
WORKER_DIR=$(pwd)

if [ -d "$GIT_DIR" ]; then
rm -rf "$GIT_DIR"
fi;

yarn docs:build
mkdir "$GIT_DIR"
cd "$GIT_DIR"

GITBRANCHDATA=$(curl https://api.github.com/repos/slimkit/plus/branches)
if echo "$GITBRANCHDATA" | grep -q "gh-pages"
then
git clone --branch=gh-pages https://github.com/slimkit/plus "$GIT_DIR"
else
git clone --branch=master https://github.com/slimkit/plus "$GIT_DIR"
git checkout --orphan gh-pages
git reset --hard
fi

# Copy dist
cp -R "$WORKER_DIR/docs/.vuepress/dist/" "$GIT_DIR/"
git add .
git commit -m "deploy"
git push --set-upstream origin gh-pages

0 comments on commit cb03e07

Please sign in to comment.