forked from gridstack/gridstack.js
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (90 loc) · 3.37 KB
/
sync-docs.yml
File metadata and controls
111 lines (90 loc) · 3.37 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Sync Documentation to gh-pages
on:
push:
branches: [master, develop]
paths:
- 'doc/html/**'
- 'angular/doc/**'
- '.github/workflows/sync-docs.yml'
workflow_dispatch:
jobs:
sync-docs:
runs-on: ubuntu-latest
if: github.repository == 'adumesny/gridstack.js'
steps:
- name: Checkout master branch
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Check if docs exist
id: check-docs
run: |
if [ -d "doc/html" ]; then
echo "main_docs=true" >> $GITHUB_OUTPUT
else
echo "main_docs=false" >> $GITHUB_OUTPUT
fi
if [ -d "angular/doc/api" ]; then
echo "angular_docs=true" >> $GITHUB_OUTPUT
else
echo "angular_docs=false" >> $GITHUB_OUTPUT
fi
- name: Checkout gh-pages branch
if: steps.check-docs.outputs.main_docs == 'true' || steps.check-docs.outputs.angular_docs == 'true'
run: |
git fetch origin gh-pages
git checkout gh-pages
- name: Sync main library documentation
if: steps.check-docs.outputs.main_docs == 'true'
run: |
echo "Syncing main library documentation..."
# Remove existing doc/html directory if it exists
if [ -d "doc/html" ]; then
rm -rf doc/html
fi
# Extract docs from master branch using git archive
mkdir -p doc
git archive master doc/html | tar -xf -
# Add changes
git add doc/html
- name: Sync Angular documentation
if: steps.check-docs.outputs.angular_docs == 'true'
run: |
echo "Syncing Angular library documentation..."
# Remove existing Angular docs if they exist
if [ -d "angular/doc" ]; then
rm -rf angular/doc
fi
# Extract Angular docs from master branch using git archive
git archive master angular/doc | tar -xf -
# Add changes
git add -f angular/doc
- name: Commit and push changes
if: steps.check-docs.outputs.main_docs == 'true' || steps.check-docs.outputs.angular_docs == 'true'
run: |
# Check if there are changes to commit
if git diff --staged --quiet; then
echo "No documentation changes to sync"
exit 0
fi
# Create commit message
COMMIT_MSG="📚 Auto-sync documentation from master"
if [ "${{ steps.check-docs.outputs.main_docs }}" == "true" ]; then
COMMIT_MSG="${COMMIT_MSG}%0A%0A- Updated main library HTML docs (docs/html/)"
fi
if [ "${{ steps.check-docs.outputs.angular_docs }}" == "true" ]; then
COMMIT_MSG="${COMMIT_MSG}%0A%0A- Updated Angular library docs (angular/doc/)"
fi
COMMIT_MSG="${COMMIT_MSG}%0A%0ASource: ${{ github.sha }}"
# Decode URL-encoded newlines for the commit message
COMMIT_MSG=$(echo -e "${COMMIT_MSG//%0A/\\n}")
# Commit and push
git commit -m "$COMMIT_MSG"
git push origin gh-pages
echo "✅ Documentation synced to gh-pages successfully!"