Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e1cbe98

Browse files
Merge pull request #3133 from adumesny/master
fix sync-doc
2 parents 5ab78e0 + b2f010d commit e1cbe98

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

β€Ž.github/workflows/sync-docs.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Sync Documentation to gh-pages
2+
3+
on:
4+
push:
5+
branches: [master, develop]
6+
paths:
7+
- 'doc/html/**'
8+
- 'angular/doc/**'
9+
- '.github/workflows/sync-docs.yml'
10+
workflow_dispatch:
11+
12+
jobs:
13+
sync-docs:
14+
runs-on: ubuntu-latest
15+
if: github.repository == 'gridstack/gridstack.js'
16+
17+
steps:
18+
- name: Checkout master branch
19+
uses: actions/checkout@v4
20+
with:
21+
ref: master
22+
fetch-depth: 0
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Configure Git
26+
run: |
27+
git config --global user.name 'github-actions[bot]'
28+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
29+
30+
- name: Check if docs exist
31+
id: check-docs
32+
run: |
33+
if [ -d "doc/html" ]; then
34+
echo "main_docs=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "main_docs=false" >> $GITHUB_OUTPUT
37+
fi
38+
39+
if [ -d "angular/doc/api" ]; then
40+
echo "angular_docs=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "angular_docs=false" >> $GITHUB_OUTPUT
43+
fi
44+
45+
- name: Checkout gh-pages branch
46+
if: steps.check-docs.outputs.main_docs == 'true' || steps.check-docs.outputs.angular_docs == 'true'
47+
run: |
48+
git fetch origin gh-pages
49+
git checkout gh-pages
50+
51+
- name: Sync main library documentation
52+
if: steps.check-docs.outputs.main_docs == 'true'
53+
run: |
54+
echo "Syncing main library documentation..."
55+
56+
# Remove existing docs directory if it exists
57+
if [ -d "docs/html" ]; then
58+
rm -rf docs/html
59+
fi
60+
61+
# Extract docs from master branch using git archive
62+
mkdir -p docs
63+
git archive master doc/html | tar -xf -
64+
mv doc/html docs/html
65+
rm -rf doc
66+
67+
# Add changes
68+
git add docs/html
69+
70+
- name: Sync Angular documentation
71+
if: steps.check-docs.outputs.angular_docs == 'true'
72+
run: |
73+
echo "Syncing Angular library documentation..."
74+
75+
# Remove existing Angular docs if they exist
76+
if [ -d "angular/doc" ]; then
77+
rm -rf angular/doc
78+
fi
79+
80+
# Extract Angular docs from master branch using git archive
81+
git archive master angular/doc | tar -xf -
82+
83+
# Add changes
84+
git add angular/doc
85+
86+
- name: Commit and push changes
87+
if: steps.check-docs.outputs.main_docs == 'true' || steps.check-docs.outputs.angular_docs == 'true'
88+
run: |
89+
# Check if there are changes to commit
90+
if git diff --staged --quiet; then
91+
echo "No documentation changes to sync"
92+
exit 0
93+
fi
94+
95+
# Create commit message
96+
COMMIT_MSG="πŸ“š Auto-sync documentation from master"
97+
if [ "${{ steps.check-docs.outputs.main_docs }}" == "true" ]; then
98+
COMMIT_MSG="${COMMIT_MSG}%0A%0A- Updated main library HTML docs (docs/html/)"
99+
fi
100+
if [ "${{ steps.check-docs.outputs.angular_docs }}" == "true" ]; then
101+
COMMIT_MSG="${COMMIT_MSG}%0A%0A- Updated Angular library docs (angular/doc/)"
102+
fi
103+
104+
COMMIT_MSG="${COMMIT_MSG}%0A%0ASource: ${{ github.sha }}"
105+
106+
# Decode URL-encoded newlines for the commit message
107+
COMMIT_MSG=$(echo -e "${COMMIT_MSG//%0A/\\n}")
108+
109+
# Commit and push
110+
git commit -m "$COMMIT_MSG"
111+
git push origin gh-pages
112+
113+
echo "βœ… Documentation synced to gh-pages successfully!"

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /