CI #16977
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: CI | |
on: | |
workflow_dispatch: | |
inputs: | |
repo: | |
description: "Source Repo" | |
required: true | |
type: choice | |
options: | |
- pingcap/docs | |
- pingcap/docs-cn | |
- pingcap/docs-dm | |
- pingcap/docs-tidb-operator | |
branch: | |
description: "Source branch" | |
type: string | |
required: true | |
full: | |
description: "Full update" | |
type: boolean | |
default: false | |
required: false | |
concurrency: ${{ github.workflow }}-${{ inputs.repo }}-${{ inputs.branch }} | |
jobs: | |
build: | |
concurrency: update-${{ inputs.repo }}-${{ inputs.branch }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: "yarn" | |
- run: yarn | |
- name: Init git info | |
run: | | |
git status | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Update target folder by event input | |
if: ${{ !inputs.full }} | |
env: | |
GITHUB_AUTHORIZATION_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
# docs-dm and docs-tidb-operator need specify language | |
if [ ${{ inputs.repo }} = "pingcap/docs-dm" ] || [ ${{ inputs.repo }} = "pingcap/docs-tidb-operator" ] | |
then | |
yarn download ${{ inputs.repo }} en --ref ${{ inputs.branch }} | |
yarn download ${{ inputs.repo }} zh --ref ${{ inputs.branch }} | |
else | |
yarn download ${{ inputs.repo }} --ref ${{ inputs.branch }} | |
fi | |
# handle tidb-cloud doc based on specified en/ja doc branch | |
if [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = "release-7.5" ] | |
then | |
yarn download:tidb-cloud:en --ref ${{ inputs.branch }} | |
elif [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = "i18n-ja-release-7.5" ] | |
then | |
yarn download:tidb-cloud:ja --ref ${{ inputs.branch }} | |
fi | |
- name: Update all folder | |
if: ${{ inputs.full }} | |
env: | |
GITHUB_AUTHORIZATION_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
sudo rm -fr ./markdown-pages/* | |
yarn download:tidb:en:all | |
yarn download:tidb-cloud:en | |
yarn download:tidb:zh:all | |
yarn download:tidb:ja:all | |
yarn download:tidb-cloud:ja | |
yarn download:dm:all | |
yarn download:tidb-operator:all | |
- name: Git commit | |
run: | | |
git add markdown-pages | |
git fetch | |
git pull | |
if [[ -z $(git status -s) ]] | |
then | |
git status | |
else | |
git commit -m "update MD by dispatch event ${{ inputs.repo }} ${{ inputs.branch }}" | |
fi | |
- name: Git push | |
uses: nick-fields/retry@v2 | |
with: | |
timeout_minutes: 3 | |
max_attempts: 3 | |
retry_on: error | |
command: | | |
git pull --rebase | |
git push | |
- name: Trigger preview | |
run: | | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \ | |
https://api.github.com/repos/pingcap/docs-staging/actions/workflows/preview.yml/dispatches \ | |
-d '{"ref":"main","inputs":{}}' | |
- name: Trigger website-docs | |
run: | | |
export CURRENT_SHA=$(git rev-parse HEAD) | |
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/production.yml/dispatches \ | |
-d '{"ref":"master","inputs":{"hash": "$CURRENT_SHA", "fallback": "false"}}' |