Skip to content

Commit 6c4a3ba

Browse files
committed
ci: optimize and fix documentation upload workflow
- Replace slow `cargo install` of mdbook and mdbook-linkcheck with direct binary downloads. - Upgrade `actions/checkout` from v2 to v4. - Do robust preparational steps and only let the last step perform a final rsync - remove some boilerplate comments
1 parent ef21e3c commit 6c4a3ba

1 file changed

Lines changed: 29 additions & 28 deletions

File tree

.github/workflows/upload-main.yml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
1-
# workflow for rendering and uploads webxdc docs
1+
# workflow for rendering and uploads webxdc docs
22

3-
name: Render and upload webxdc docs
3+
name: Render and upload webxdc docs
44

5-
# Controls when the workflow will run
65
on:
7-
# Triggers the workflow on push or pull request events but only for the master branch
86
push:
9-
branches:
7+
branches:
108
- main
11-
12-
# Allows you to run this workflow manually from the Actions tab
139
workflow_dispatch:
1410

15-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1611
jobs:
17-
# This workflow contains a single job called "build"
1812
build:
19-
# The type of runner that the job will run on
2013
runs-on: ubuntu-latest
2114

22-
# Steps represent a sequence of tasks that will be executed as part of the job
2315
steps:
24-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25-
- uses: actions/checkout@v2
16+
- name: Checkout code
17+
uses: actions/checkout@v4
2618

27-
- uses: actions-rs/toolchain@v1
28-
with:
29-
profile: minimal
30-
toolchain: stable
31-
override: true
19+
- name: Setup mdBook
20+
run: |
21+
MDBOOK_VERSION="0.4.40"
22+
curl -sSL "https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz" | tar -xz
23+
sudo mv mdbook /usr/local/bin/
3224
33-
- name: Rust Cache
34-
uses: Swatinem/rust-cache@v1.3.0
25+
- name: Install mdbook-linkcheck
26+
run: |
27+
curl -sSL "https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/latest/download/mdbook-linkcheck.x86_64-unknown-linux-gnu.zip" -o mdbook-linkcheck.zip
28+
unzip mdbook-linkcheck.zip mdbook-linkcheck
29+
chmod +x mdbook-linkcheck
30+
sudo mv mdbook-linkcheck /usr/local/bin/
3531
36-
- name: install mdbook
32+
- name: Build docs
3733
run: |
38-
cargo install mdbook --vers "^0.4"
39-
cargo install mdbook-linkcheck
40-
cd src-docs
34+
cd src-docs
4135
mdbook build
42-
mv book/html ../website/docs
36+
mkdir -p ../website/docs
37+
cp -r book/html/* ../website/docs/
38+
39+
- name: Prepare website and apps
40+
run: |
41+
# Ensure website/apps exists and copy contents
42+
mkdir -p website/apps
43+
cp -r apps/* website/apps/
4344
44-
- name: Upload website including docs and apps
45+
- name: Upload website including docs and apps
4546
run: |
4647
mkdir -p "$HOME/.ssh"
4748
echo "${{ secrets.KEY }}" > "$HOME/.ssh/key"
4849
chmod 600 "$HOME/.ssh/key"
49-
mv apps website/
50-
rsync -avzh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" "website/" "${{ secrets.USERNAME }}@delta.chat:/var/www/html/webxdc.org"
50+
# Rsync using the correct source and target
51+
rsync -avzh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" "website/" "${{ secrets.USERNAME }}@delta.chat:/var/www/html/webxdc.org"

0 commit comments

Comments
 (0)