Update preview branch #15352
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update preview branch | |
on: | |
# push: | |
# branches: ["main"] | |
# paths-ignore: | |
# - ".github/**" | |
workflow_dispatch | |
concurrency: update-preview-branch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: "main" | |
path: "main" | |
- uses: actions/checkout@v3 | |
with: | |
ref: "preview" | |
path: "preview" | |
- name: Init git info | |
run: | | |
cd preview | |
git status | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Update preview branch files | |
run: | | |
sudo rm -fr ./preview/markdown-pages/* | |
sudo rm -fr ./preview/docs.json | |
cp -rip ./main/docs.json ./preview/docs.json | |
mkdir -p ./preview/markdown-pages/en/tidb | |
mkdir -p ./preview/markdown-pages/ja/tidb | |
mkdir -p ./preview/markdown-pages/en/tidbcloud | |
mkdir -p ./preview/markdown-pages/zh/tidb | |
cp -rip ./main/markdown-pages/en/tidb/master ./preview/markdown-pages/en/tidb/master | |
cp -rip ./main/markdown-pages/en/tidb/release-8.1 ./preview/markdown-pages/en/tidb/release-8.1 | |
cp -rip ./main/markdown-pages/en/tidbcloud ./preview/markdown-pages/en/ | |
cp -rip ./main/markdown-pages/zh/tidb/release-8.1 ./preview/markdown-pages/zh/tidb/release-8.1 | |
cp -rip ./main/markdown-pages/zh/tidb/master ./preview/markdown-pages/zh/tidb/master | |
cp -rip ./main/markdown-pages/ja/tidb/release-8.1 ./preview/markdown-pages/ja/tidb/release-8.1 | |
cp -rip ./main/markdown-pages/ja/tidbcloud ./preview/markdown-pages/ja/ | |
- name: Git commit and push | |
run: | | |
cd preview | |
git add markdown-pages | |
git add docs.json | |
git fetch | |
git pull | |
if [[ -z $(git status -s) ]] | |
then | |
git status | |
else | |
git commit -m "update MDs by main branch" | |
fi | |
git push | |
# - name: Trigger website-docs-preview | |
# run: | | |
# curl \ | |
# -X POST \ | |
# -H "Accept: application/vnd.github+json" \ | |
# -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ | |
# https://api.github.com/repos/pingcap/website-docs/actions/workflows/preview.yml/dispatches \ | |
# -d '{"ref":"master","inputs":{}' |