Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
Signed-off-by: Kang Huaishuai <[email protected]>
  • Loading branch information
khs1994 committed Jul 20, 2021
0 parents commit b3ebea8
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/gitbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
branches:
- master
pull_request:

name: GitBook

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 2
- name: gitbook-build
uses: docker://khs1994/gitbook
- name: gitbook-deploy
if: github.event_name == 'push'
uses: docker://khs1994/gitbook
with:
args: deploy
env:
GIT_USERNAME: "khs1994"
GIT_USEREMAIL: "[email protected]"
GIT_BRANCH: "gh-pages"
# 必须使用自己的 token, actions 的 token 不会触发 master 的 actions
GITHUB_TOKEN: ${{ secrets.PCIT_GIT_TOKEN }}
68 changes: 68 additions & 0 deletions .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
on:
push:
branches:
- sync
pull_request:
schedule:
- cron: '0 0 */1 * *'
workflow_dispatch:

name: Sync

jobs:
sync-from-upstream:
name: Sync-From-Upstream
runs-on: ubuntu-latest
strategy:
matrix:
include:
- SRC_FOLDER: 'content'
GIT_URL: 'https://github.com/github/docs'
GITBOOK_TITLE: '[GitHub 英文文档](https://github.com/github/docs)'
USER_AND_REPO: 'github/docs'
steps:
- uses: actions/checkout@master
with:
fetch-depth: 2
- name: Fetch upstream
run: |
set -x
git clone --depth=1 ${GIT_URL} dist
UPSTREAM_COMMIT_SHA=`git -C dist log --abbrev-commit --pretty="%h" -1`
echo "::set-output name=UPSTREAM_COMMIT_SHA::${UPSTREAM_COMMIT_SHA}"
env:
GIT_URL: ${{ matrix.GIT_URL }}
id: upstream
- name: Generate SUMMARY
env:
SRC_FOLDER: dist/${{ matrix.SRC_FOLDER }}
GITBOOK_TITLE: ${{ matrix.GITBOOK_TITLE }}
run: |
set -x
mkdir -p ${SRC_FOLDER}/.github/workflows
cp -a .github/workflows/gitbook.yaml ${SRC_FOLDER}/.github/workflows/
cp book.json ${SRC_FOLDER}
cd ${SRC_FOLDER}
# mv index.md README.md
npm init -f
npm install gitbook-summary
npx book sm -t "${GITBOOK_TITLE}" -i node_modules
rm -rf node_modules package.json package-lock.json
ls -la
- name: Push docs src
if: |
github.event_name == 'push'
|| github.event_name == 'schedule'
|| github.event_name == 'workflow_dispatch'
uses: docker://pcit/pages
env:
PCIT_EMAIL: [email protected]
# 必须使用自己的 token, actions 的 token 不会触发 master 的 actions
PCIT_GIT_TOKEN: ${{ secrets.PCIT_GIT_TOKEN }}
PCIT_GIT_URL: github.com/${{ github.repository }}
PCIT_KEEP_HISTORY: "true"
PCIT_LOCAL_DIR: dist/${{ matrix.SRC_FOLDER }}
PCIT_MESSAGE: Sync from ${{ matrix.USER_AND_REPO }}@${{ steps.upstream.outputs.UPSTREAM_COMMIT_SHA }} by PCIT
PCIT_TARGET_BRANCH: master
PCIT_USERNAME: khs1994
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 文档源码请查看 master 分支

[![](https://github.com/khs1994-website/github-docs.us-en/workflows/Sync/badge.svg)](https://github.com/khs1994-website/github-docs.us-en/tree/master)

[![](https://github.com/khs1994-website/github-docs.us-en/workflows/GitBook/badge.svg)](https://github.com/khs1994-website/github-docs.us-en/tree/master)
22 changes: 22 additions & 0 deletions book.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"title": "GitHub 英文文档",
"language": "us-en",
"links": {
"sidebar": {
"Home": "https://docs.khs1994.com"
}
},
"plugins": [
"-sharing",
"-highlight",
"-livereload",
"prism"
],
"pluginsConfig": {
"prism": {
"css": [
"prismjs/themes/prism-solarizedlight.css"
]
}
}
}

0 comments on commit b3ebea8

Please sign in to comment.