Skip to content

Commit 94fd1fc

Browse files
authored
Add docs auto-deploy to CI (#1636)
* Add docs auto-deploy to CI * Prevent nested html directory in docs deployment * Update deployed branch name to master
1 parent 5dd61b8 commit 94fd1fc

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import tempfile
5+
import subprocess
6+
from typing import Tuple
7+
from pathlib import Path
8+
import shlex
9+
10+
KNOWN_HOSTS = '''
11+
flexflow.ai ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAING3BmAIYc0G5hxIFPqQrgLjCt2t4vlRaLxds3QY6MaE
12+
'''
13+
14+
def create_ssh_key_file(d: Path) -> Tuple[Path, Path]:
15+
d.chmod(0o700)
16+
17+
ssh_private_key_path = d / 'id_ed25519'
18+
ssh_private_key_path.touch(mode=0o600, exist_ok=False)
19+
20+
ssh_known_hosts_path = d / 'known_hosts'
21+
ssh_known_hosts_path.touch(mode=0o600, exist_ok=False)
22+
23+
ssh_private_key_path.write_text(os.environ['SSH_PRIVATE_KEY'] + '\n')
24+
ssh_known_hosts_path.write_text(KNOWN_HOSTS)
25+
26+
return ssh_private_key_path, ssh_known_hosts_path
27+
28+
def deploy(ssh_private_key_path: Path, ssh_known_hosts_path: Path) -> None:
29+
assert ssh_private_key_path.is_file()
30+
assert ssh_known_hosts_path.is_file()
31+
32+
docs_html_dir = Path('./build/doxygen/html/')
33+
assert docs_html_dir.is_dir()
34+
assert (docs_html_dir / 'index.html').is_file()
35+
36+
ssh_command = shlex.join([
37+
'ssh', '-i', str(ssh_private_key_path), '-o', f'UserKnownHostsFile={ssh_known_hosts_path}',
38+
])
39+
print(ssh_command)
40+
subprocess.run(
41+
[
42+
'rsync',
43+
'--delete',
44+
'--recursive',
45+
'--verbose',
46+
'--human-readable',
47+
f'--rsh={ssh_command}',
48+
str(docs_html_dir) + '/',
49+
'deploy-ff-train-docs@flexflow.ai:/opt/www/ff-train-docs/',
50+
],
51+
check=True,
52+
)
53+
54+
if __name__ == '__main__':
55+
with tempfile.TemporaryDirectory() as _d:
56+
d = Path(_d)
57+
58+
ssh_private_key_path, ssh_known_hosts_path = create_ssh_key_file(d)
59+
60+
deploy(
61+
ssh_private_key_path=ssh_private_key_path,
62+
ssh_known_hosts_path=ssh_known_hosts_path,
63+
)

.github/workflows/tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ jobs:
4343
run: |
4444
proj check cpu-ci
4545
46+
- name: Deploy docs to flexflow.ai
47+
env:
48+
SSH_PRIVATE_KEY: ${{secrets.DOCS_SSH_PRIVATE_KEY}}
49+
if: ${{ success() && ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' ) && github.ref == 'refs/heads/master' }}
50+
run: |
51+
./.github/workflows/helpers/deploy-docs.py
52+
4653
- name: Upload code coverage
4754
uses: codecov/codecov-action@v4
4855
with:

0 commit comments

Comments
 (0)