Skip to content

Sync

Sync #951

Workflow file for this run

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