Skip to content

Commit 4ecf5c1

Browse files
authored
docs: add docs request trigger to sync docs (alibaba#108)
* docs: add docs trigger sh and workflow * docs: update doc tips * docs: add paths to docs-request-trigger * docs: debug in custom branch * docs: debug in custom branch * docs: add checkout_submodules * docs: add check_user_name and check_token to sync docs workflow
1 parent 32613ad commit 4ecf5c1

File tree

4 files changed

+98
-3
lines changed

4 files changed

+98
-3
lines changed

.github/scripts/trigger-docs.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# Check if two arguments are provided
4+
if [ $# -ne 6 ]; then
5+
echo "Usage: $0 <COMMIT_ID> <SECURITY> <GITHUB_SOURCE_REPO> <GITHUB_PR_ID> <CHECK_USER_NAME> <CHECK_TOKEN>"
6+
exit 1
7+
fi
8+
9+
# Read commitId, repositoryUrl, and security from parameters or environment variables
10+
COMMIT_ID=$1
11+
SECURITY=$2
12+
REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git"
13+
PROJECT_ID="3567319"
14+
BRANCH_REF="master"
15+
CANCEL_IN_PROGRESS="true"
16+
PIPELINE_ID="49245"
17+
GITHUB_COMMIT_ID="${COMMIT_ID}"
18+
GITHUB_SOURCE_REPO=$3
19+
GITHUB_PR_ID=$4
20+
CHECK_USER_NAME=$5
21+
CHECK_TOKEN=$6
22+
BRANCH_NAME="open_merge_docs/${GITHUB_PR_ID}"
23+
CHECKOUT_SUBMODULES="true"
24+
25+
# Get current timestamp
26+
timestamp=$(date +%s)
27+
28+
# Concatenate the parameters with timestamp
29+
combined="${COMMIT_ID}${SECURITY}${timestamp}"
30+
31+
# Calculate the MD5 hash
32+
base64_hash=$(echo -n "${combined}" | base64)
33+
34+
# Return the MD5 hash as the script's exit code
35+
echo "${SECURITY}"
36+
37+
# 发送 CREATE-TASK 请求
38+
curl -v -H "Content-Type: application/json" \
39+
-H "Authorization: Basic ${SECURITY}" \
40+
-d "{
41+
\"type\": \"CREATE-TASK\",
42+
\"commitId\": \"${COMMIT_ID}\",
43+
\"repositoryUrl\": \"${REPO_URL}\",
44+
\"aone\": { \"projectId\": \"${PROJECT_ID}\", \"pipelineId\": \"${PIPELINE_ID}\"},
45+
\"newBranch\": { \"name\": \"${BRANCH_NAME}\", \"ref\": \"${BRANCH_REF}\" },
46+
\"params\": {\"cancel-in-progress\": \"${CANCEL_IN_PROGRESS}\", \"github_commit\":\"${GITHUB_COMMIT_ID}\", \"github_source_repo\": \"${GITHUB_SOURCE_REPO}\", \"checkout_submodules\": \"${CHECKOUT_SUBMODULES}\", \"checkout_username\": \"${CHECK_USER_NAME}\", \"checkout_token\": \"${CHECK_TOKEN}\"}
47+
}" \
48+
"http://triggerid-to-mq-wjrdhcgbie.cn-hangzhou.fcapp.run"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Docs Request Trigger
4+
5+
# Controls when the workflow will run
6+
on:
7+
pull_request:
8+
branches: [ "master" ]
9+
paths:
10+
- '.github/workflows/docs-request-trigger.yml'
11+
- 'docs/**'
12+
types: [closed]
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
19+
cancel-in-progress: true
20+
21+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
22+
jobs:
23+
# This workflow contains a single job called "build"
24+
build:
25+
if: github.event.pull_request.merged == true
26+
# The type of runner that the job will run on
27+
runs-on: ubuntu-latest
28+
# work on CI script dir
29+
defaults:
30+
run:
31+
working-directory: .github/scripts
32+
# Steps represent a sequence of tasks that will be executed as part of the job
33+
steps:
34+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35+
- uses: actions/checkout@v4
36+
37+
# Runs trigger CI
38+
- name: Make the script files executable
39+
run: chmod +x trigger-docs.sh
40+
- name: trigger a CI
41+
run: |
42+
COMMIT_ID=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.event.pull_request.head.sha }}" || echo "${{ github.sha }}")
43+
echo "Using Commit ID: $COMMIT_ID"
44+
echo "$GITHUB_REF"
45+
PR_ID=$(echo "$GITHUB_REF" | sed 's@refs/pull/\([0-9]\+\)/.*@\1@')
46+
echo "PR ID is $PR_ID"
47+
./trigger-docs.sh "$COMMIT_ID" "${{ secrets.CI_SECRET }}" "${{ github.event.pull_request.head.repo.clone_url }}" "$PR_ID" "${{ secrets.CHECK_USER_NAME }}" "${{ secrets.CHECK_TOKEN }}"

docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
title: 文档提示
33
---
44

5-
请根据版本号修改 versioned_docs 文件夹中对应版本的文档
5+
请根据版本号修改对应版本的文档内容
66

7-
例如,如果版本号是 0.2.x,请修改 versioned_docs/version-0.2.x 文件夹中的相应文档。
7+
例如,如果版本号是 0.2.x,请修改`docs/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.2.x` 文件夹中的相应文档。

docs/rock/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ title: Document Tip
44

55
Please modify the documentation by editing the corresponding versioned documents in the versioned_docs folder according to the version number.
66

7-
For example, if the version number is 0.2.x, please modify the corresponding document in the versioned_docs/version-0.2.x folder.
7+
For example, if the version number is 0.2.x, please modify the corresponding document in the `docs/versioned_docs/version-0.2.x` folder.

0 commit comments

Comments
 (0)