Skip to content

Commit ffc2762

Browse files
authored
ci: improve the 'Publish website' step (#1046)
This makes that step use rsync to upload the website and demos. Besides supporting compression, rsync also only sends the changes over the wire. This improves the performance of that step by a wide margin, reducing normal upload times from almost 9 minutes down to about 20s for the most common changes. This uses rsync's ability to also remove stale files, to make sure we don't leave old files behind. (This ignores the directories which are handled separately, like llvm+clang and demos). There were some pretty stale things left behind that this now removes, such as a sitemap.xml which was generated last year. Fixes #1039
1 parent 88954d7 commit ffc2762

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ jobs:
581581
uses: alandefreitas/cpp-actions/package-install@v1.8.12
582582
id: package-install
583583
with:
584-
apt-get: build-essential asciidoctor cmake bzip2 git
584+
apt-get: build-essential asciidoctor cmake bzip2 git rsync
585585

586586
- name: Clone MrDocs
587587
uses: actions/checkout@v4
@@ -711,6 +711,7 @@ jobs:
711711
node render.js
712712
mkdir -p ../../build/website
713713
cp index.html ../../build/website/index.html
714+
cp robots.txt ../../build/website/robots.txt
714715
cp styles.css ../../build/website/styles.css
715716
cp -r assets ../../build/website/assets
716717
@@ -963,6 +964,7 @@ jobs:
963964
env:
964965
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
965966
run: |
967+
set -euvx
966968
# Add SSH key
967969
mkdir -p /home/runner/.ssh
968970
ssh-keyscan dev-websites.cpp.al >> /home/runner/.ssh/known_hosts
@@ -972,17 +974,15 @@ jobs:
972974
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
973975
ssh-add /home/runner/.ssh/github_actions
974976
977+
rsyncopts=(--recursive --delete --links --times --chmod=D0755,F0755 --compress --compress-choice=zstd --rsh="ssh -o StrictHostKeyChecking=no" --human-readable)
978+
website_dir="ubuntu@dev-websites.cpp.al:/var/www/mrdox.com"
979+
demo_dir="$website_dir/demos/${{ github.ref_name }}"
980+
975981
# Copy files: This step will copy the landing page and the documentation to www.mrdocs.com
976-
chmod 755 -R $(pwd)/build/website
977-
scp -o StrictHostKeyChecking=no -r $(pwd)/build/website/* ubuntu@dev-websites.cpp.al:/var/www/mrdox.com/
978-
979-
# Remove previous demos associated with this tag
980-
demo_dir="/var/www/mrdox.com/demos/${{ github.ref_name }}"
981-
ssh -o StrictHostKeyChecking=no ubuntu@dev-websites.cpp.al "rm -rf $demo_dir/boost-url; mkdir -p $demo_dir/boost-url"
982+
time rsync "${rsyncopts[@]}" --exclude=llvm+clang/ --exclude=demos/ $(pwd)/build/website/ "$website_dir"/
982983
983984
# Copy demos: This step will copy the demos to www.mrdocs.com/demos
984-
chmod 755 -R $(pwd)/demos
985-
scp -o StrictHostKeyChecking=no -r $(pwd)/demos/* ubuntu@dev-websites.cpp.al:$demo_dir/
985+
time rsync "${rsyncopts[@]}" $(pwd)/demos/ "$demo_dir"/
986986
987987
- name: Create changelog
988988
uses: alandefreitas/cpp-actions/create-changelog@v1.8.12

docs/website/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Allow: /

0 commit comments

Comments
 (0)