-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (65 loc) · 2.24 KB
/
sync.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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/en/docs/v3.5'
GIT_URL: 'https://github.com/etcd-io/website'
GITBOOK_TITLE: '[etcd 英文文档](https://github.com/etcd-io/website)'
USER_AND_REPO: 'etcd-io/website'
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