diff --git a/.github/workflows/preview-mult-pr.yml b/.github/workflows/preview-mult-pr.yml new file mode 100644 index 0000000000..73f53a3d84 --- /dev/null +++ b/.github/workflows/preview-mult-pr.yml @@ -0,0 +1,23 @@ +name: Preview multiple PRs + +on: + workflow_dispatch: + schedule: + - cron: '0 */8 * * *' + +jobs: + sync: + runs-on: ubuntu-latest + + steps: + - name: Check out destination repository + uses: actions/checkout@v3 + + - name: Sync PR + run: | + git config user.name github-actions + git config user.email github-actions@github.com + ./sync_mult_prs.sh + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-files.yml b/.github/workflows/update-files.yml index 7366a41cb5..9eb31e937d 100644 --- a/.github/workflows/update-files.yml +++ b/.github/workflows/update-files.yml @@ -2,8 +2,8 @@ name: Update scaffold on: workflow_dispatch: - schedule: - - cron: "0 0 */15 * *" + # schedule: + # - cron: "0 0 */15 * *" jobs: copy_files: diff --git a/README.md b/README.md index f9ca5f0910..4166a57563 100644 --- a/README.md +++ b/README.md @@ -6,42 +6,20 @@ To create a **production** build, you can run the `./build.sh` script. To create a **development** build, you can run the `./build.sh` script with `dev` or `develop` argument. -## Workflow +## How to preview multiple PRs? -### Overview +1. Create a new branch from the `mult-pr-preview` branch. -![image](https://user-images.githubusercontent.com/56986964/183846841-d8a0027d-21cf-4d73-970d-89df0e456102.png) + Note: the new branch name cannot be `preview/**`, `preview-cloud/**`, or `preview-operator/**`. -### How Docs Staging Update Itself +2. Configure the following files: -#### 1. Trigger by event from Docs Source Repo + - `sync_mult_prs.sh`: Replace `{PR_NUMBER_x}` and `{release-x.y}` with the actual PR numbers and release version you want to preview. + - `preview-mult-pr.yml`: Set the schedule for automatic PR preview. + - `docs.json` (optional): Add a new entry for the release version you're previewing or update the existing configuration, such as the stable version. -![image](https://user-images.githubusercontent.com/56986964/183847182-73d83a99-5af3-43aa-9bfa-e0e2d3cbe2f2.png) +3. Set the new branch as the default branch for the repository. -#### 2. Trigger by event manually +4. Manually trigger the `preview-mult-pr.yml` workflow to preview the PRs and validate the configuration. -![image](https://user-images.githubusercontent.com/56986964/183847213-bc18a345-f17b-473f-84a9-ca05215be3b7.png) - -## Config Actions Secrets - -### 1. Install `Surge.sh` CLI - -```bash -npm install --global surge -``` - -### 2. Login `Surge.sh` - -```bash -surge login -``` - -### 3. Create `Surge.sh` Token - -```bash -surge token -``` - -### 4. Config `Surge.sh` Token - -Visit `/settings/secrets/actions` and add `SURGE_TOKEN` with the token you just created. +After setup, the workflow will automatically run on the schedule defined in `preview-mult-pr.yml` to preview the PRs. diff --git a/sync_mult_prs.sh b/sync_mult_prs.sh new file mode 100755 index 0000000000..9260109226 --- /dev/null +++ b/sync_mult_prs.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd "$SCRIPT_DIR" + +./sync.sh preview/pingcap/docs/{PR_NUMBER_1} +./sync.sh preview/pingcap/docs/{PR_NUMBER_2} +./sync.sh preview/pingcap/docs-cn/{PR_NUMBER_3} +./sync.sh preview/pingcap/docs-cn/{PR_NUMBER_4} +rsync -av markdown-pages/zh/tidb/master/ markdown-pages/zh/tidb/{release-x.y}/ +rsync -av markdown-pages/en/tidb/master/ markdown-pages/en/tidb/{release-x.y}/ + +git add . +git commit -m "update {release-x.y}" || echo "No changes to commit"