-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 2.03 KB
/
sync-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Auto-Sync Docs from Repositories
on:
schedule:
- cron: "0 2 * * *" # Runs daily at 2 AM UTC
workflow_dispatch:
repository_dispatch:
types: [sync-docs]
jobs:
sync-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub Pages Repo
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Fetch Repo List from GitHub API
env:
GH_PAT: ${{ secrets.ORG_REPO_TOKEN }}
run: |
curl -s -H "Authorization: token $GH_PAT" \
"https://api.github.com/orgs/khulnasoft/repos?per_page=100" \
| jq -r '.[].name' > repos.txt
echo "Updated repos.txt:"
cat repos.txt
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Clone and Sync Docs
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
mkdir -p repos docs && cd repos
while IFS= read -r REPO; do
echo "Cloning $REPO..."
git clone --depth 1 https://x-access-token:[email protected]/khulnasoft/$REPO.git || {
echo "Failed to clone $REPO. Skipping...";
continue;
}
mkdir -p ../docs/$REPO
if [ -d "$REPO/docs" ]; then
cp -r $REPO/docs/* ../docs/$REPO/
elif [ -f "$REPO/README.md" ]; then
cp $REPO/README.md ../docs/$REPO.md
else
echo "Warning: No docs found for $REPO. Skipping..."
fi
rm -rf $REPO
done < ../repos.txt
cd ..
- name: Commit & Push Changes
run: |
git add .
if git diff --cached --quiet; then
echo "No changes detected."
else
git commit -m "Auto-sync latest docs from all repos"
git push "https://x-access-token:[email protected]/khulnasoft/khulnasoft.github.io.git" master