Skip to content

Commit

Permalink
init preview multiple PRs
Browse files Browse the repository at this point in the history
Signed-off-by: Aolin <[email protected]>
  • Loading branch information
Oreoxmt committed Jul 25, 2023
1 parent c6724ea commit 32d6dc6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/preview-mult-pr.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]
./sync_mult_prs.sh
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/update-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Update scaffold

on:
workflow_dispatch:
schedule:
- cron: "0 0 */15 * *"
# schedule:
# - cron: "0 0 */15 * *"

jobs:
copy_files:
Expand Down
42 changes: 10 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<Your Repo URL>/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.
15 changes: 15 additions & 0 deletions sync_mult_prs.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 32d6dc6

Please sign in to comment.