Skip to content

Update docs.tidb.io #38

Update docs.tidb.io

Update docs.tidb.io #38

Workflow file for this run

name: Update docs.tidb.io
on:
workflow_dispatch:
inputs:
repo:
description: "Source Repo"
required: true
type: choice
options:
- pingcap/docs
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
with:
ref: "tidb-cloud"
- 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: |
yarn download:tidb-cloud:en --ref ${{ inputs.branch }}
- name: Update all folder
if: ${{ inputs.full }}
env:
GITHUB_AUTHORIZATION_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
sudo rm -fr ./markdown-pages/*
yarn download:tidb-cloud:en --ref ${{ inputs.branch }}
- 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":"tidb-cloud","inputs":{"hash": "$CURRENT_SHA", "fallback": "false"}}'