-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
97 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
repositories: | ||
- source_repo: "https://github.com/rooch-network/rooch.git" | ||
source_branch: "main" | ||
target_path: "rooch_docs" | ||
patterns: | ||
- "+ docs/" | ||
- "+ docs/**/" | ||
- "+ frameworks/" | ||
- "+ frameworks/**/" | ||
- "+ /crates/" | ||
- "+ /crates/rooch-open-rpc-spec/" | ||
- "+ crates/rooch-open-rpc-spec/schemas/" | ||
- "+ crates/rooch-open-rpc-spec/schemas/*.json" | ||
- "- **/_*.mdx" | ||
- "+ **/*.mdx" | ||
- "+ **/*.md" | ||
|
||
- source_repo: "https://github.com/rooch-network/rooch-book.git" | ||
source_branch: "main" | ||
target_path: "rooch_book" | ||
patterns: | ||
- "+ docs/" | ||
- "+ docs/**/" | ||
- "+ **/*.md" | ||
|
||
- source_repo: "https://github.com/bitcoin/bitcoin.git" | ||
source_branch: "master" | ||
target_path: "bitcoin" | ||
patterns: | ||
- "+ doc/" | ||
- "+ doc/**/" | ||
- "+ **/*.md" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 检查是否提供了配置文件参数 | ||
if [ $# -eq 0 ]; then | ||
echo "Usage: $0 <config-file>" | ||
exit 1 | ||
fi | ||
|
||
# 使用第一个命令行参数作为配置文件路径 | ||
CONFIG_FILE="$1" | ||
|
||
# Parse config and execute sync | ||
CONFIG=$(cat "$CONFIG_FILE" | yq -o json) | ||
echo "$CONFIG" | jq -c '.repositories[]' | while read -r repo; do | ||
source_repo=$(echo $repo | jq -r '.source_repo') | ||
source_branch=$(echo $repo | jq -r '.source_branch') | ||
target_path=$(echo $repo | jq -r '.target_path') | ||
patterns=$(echo $repo | jq -r '.patterns[]') | ||
|
||
# Create temporary directory | ||
TEMP_DIR=$(mktemp -d) | ||
|
||
# Clone source repository | ||
git clone --depth 1 -b $source_branch $source_repo $TEMP_DIR | ||
|
||
# Create filter rules file | ||
echo "$patterns" > $TEMP_DIR/filter-rules.txt | ||
|
||
# Use rsync for sync | ||
rsync -av --delete \ | ||
--include-from=$TEMP_DIR/filter-rules.txt \ | ||
--exclude='*' \ | ||
$TEMP_DIR/ $target_path/ | ||
|
||
# Clean temporary directory | ||
rm -rf $TEMP_DIR | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,40 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
name: Sync Knowledge | ||
|
||
name: CI | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "main" branch | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 2 * * *' | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
sync: | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
- name: Checkout target repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
# Runs a single command using the runners shell | ||
- name: Run a one-line script | ||
run: echo Hello, world! | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install -y rsync | ||
pip install yq | ||
- name: Sync repositories | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
./.github/sync.sh .github/sync-config.yml | ||
# Runs a set of commands using the runners shell | ||
- name: Run a multi-line script | ||
- name: Commit changes | ||
run: | | ||
echo Add other actions to build, | ||
echo test, and deploy your project. | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
git add . | ||
git commit -m "sync: update from external repositories" | ||
git push | ||
fi |