Skip to content

Commit fa9c947

Browse files
authored
Merge pull request #1498 from yashisrani/kmeshctl-syncing-tool
feature(workflow): added Kmeshctl doc syncing workflow
2 parents 7193230 + 6fd6a3a commit fa9c947

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Sync kmeshctl Docs to Website (via PR)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- docs/ctl/**
9+
- .github/workflows/sync-kmeshctl-docs.yml
10+
11+
jobs:
12+
sync-docs:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: 🧭 Checkout website repository
17+
uses: actions/checkout@v4
18+
with:
19+
repository: kmesh-net/website
20+
token: ${{ secrets.GH_PAT }}
21+
path: website
22+
ref: main
23+
fetch-depth: 1
24+
25+
- name: 🧭 Checkout kmesh repository
26+
uses: actions/checkout@v4
27+
with:
28+
repository: kmesh-net/kmesh
29+
token: ${{ secrets.GH_PAT }}
30+
path: kmesh
31+
fetch-depth: 1
32+
33+
- name: 🔁 Sync kmeshctl Docs Using rsync
34+
run: |
35+
set -e
36+
37+
# Define source and target directories
38+
KMESH_CTL_DIR="kmesh/docs/ctl"
39+
WEBSITE_KMESHCTL_DIR="website/docs/kmeshctl"
40+
41+
echo "🔍 Source directory: $KMESH_CTL_DIR"
42+
echo "🎯 Target directory: $WEBSITE_KMESHCTL_DIR"
43+
44+
# Check if source directory exists
45+
if [ ! -d "$KMESH_CTL_DIR" ]; then
46+
echo "❌ ERROR: Source directory does not exist!"
47+
exit 1
48+
fi
49+
50+
# Create target directory if it doesn't exist
51+
if [ ! -d "$WEBSITE_KMESHCTL_DIR" ]; then
52+
echo "📁 Creating $WEBSITE_KMESHCTL_DIR..."
53+
mkdir -p "$WEBSITE_KMESHCTL_DIR"
54+
fi
55+
56+
# Sync files using rsync
57+
echo "🔄 Syncing files with rsync..."
58+
rsync -avc --delete --exclude='.git' --exclude='.*' "$KMESH_CTL_DIR/" "$WEBSITE_KMESHCTL_DIR/"
59+
60+
# Navigate to the website repository
61+
cd website
62+
63+
# Stage changes
64+
git add -A docs/kmeshctl/
65+
66+
# Check if there are any changes
67+
if git diff --cached --quiet; then
68+
echo "✅ No changes detected."
69+
exit 0
70+
else
71+
echo "✨ Changes detected. Creating commit..."
72+
git config user.name "github-actions[bot]"
73+
git config user.email "github-actions[bot]@users.noreply.github.com"
74+
git commit -m 'docs: sync kmeshctl docs from kmesh-net/kmesh'
75+
fi
76+
77+
- name: 🤝 Create Pull Request
78+
uses: peter-evans/create-pull-request@v5
79+
with:
80+
token: ${{ secrets.GH_PAT }}
81+
path: website
82+
branch-suffix: timestamp
83+
base: main
84+
title: "docs: sync latest kmeshctl documentation (commit ${{ github.sha }})"
85+
body: |
86+
This PR syncs the latest changes from [kmesh/docs/ctl](https://github.com/kmesh-net/kmesh/tree/main/docs/ctl).
87+
88+
**Triggered by commit:** ${{ github.sha }}
89+
90+
Please review and merge.
91+
commit-message: "docs: sync kmeshctl docs"
92+
delete-branch: true

0 commit comments

Comments
 (0)