Skip to content

Commit 51b9914

Browse files
authored
[CI] Add github workflow for updating the website. NFC (#25793)
1 parent 0cd0fab commit 51b9914

File tree

3 files changed

+64
-7
lines changed

3 files changed

+64
-7
lines changed

.github/workflows/rebaseline-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ jobs:
5858
fi
5959
fi
6060
git push origin rebaseline_tests
61-
gh pr create --fill --base ${{ github.ref_name }}
61+
gh pr create --fill --base ${{ github.ref_name }} --reviewer sbc100,kripken
6262
gh pr merge --squash --auto
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Update website
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
update-website:
9+
name: Update website
10+
runs-on: ubuntu-latest
11+
env:
12+
GH_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
submodules: true
19+
- name: Checkout website repo
20+
uses: actions/checkout@v4
21+
with:
22+
repository: kripken/emscripten-site
23+
ref: gh-pages
24+
path: ../emscripten-site
25+
- name: pip install
26+
run: |
27+
which python3
28+
python3 --version
29+
python3 -m pip install -r requirements-dev.txt
30+
- name: Update docs
31+
run: |
32+
git config user.name emscripten-bot
33+
git config user.email emscripten-bot@users.noreply.github.com
34+
./bootstrap
35+
if ./tools/maint/update_docs.py; then
36+
echo "rebaseline_tests returned zero, expectations up-to-date"
37+
# Exit early and don't create a PR
38+
exit 0
39+
else
40+
code=$?
41+
if [[ $code != 2 ]] ; then
42+
echo "rebaseline_docs.py failed with unexpected error $code (expected 2)"
43+
exit 1
44+
fi
45+
fi
46+
# Create a PR against the emscripten-site repo
47+
cd ../emscripten-site
48+
git push origin update
49+
gh pr create --fill --base gh-pages --reviewer sbc100,kripken
50+
gh pr merge --squash --auto

tools/maint/update_docs.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
site_dir = os.path.join(root_dir, 'site')
1717

1818

19-
def check_git_clean(dirname):
20-
if subprocess.check_output(['git', 'status', '-uno', '--porcelain'], text=True, cwd=dirname).strip():
21-
print(f'{dirname}: tree is not clean')
22-
sys.exit(1)
19+
def is_git_clean(dirname):
20+
return subprocess.check_output(['git', 'status', '-uno', '--porcelain'], text=True, cwd=dirname).strip() == ''
2321

2422

2523
def main(args):
@@ -30,8 +28,12 @@ def main(args):
3028

3129
assert os.path.isdir(site_out)
3230
print(f'Updating docs in: {site_out}')
33-
check_git_clean(site_out)
34-
check_git_clean(root_dir)
31+
if not is_git_clean(site_out):
32+
print(f'{site_out}: tree is not clean')
33+
return 1
34+
if not is_git_clean(root_dir):
35+
print(f'{root_dir}: tree is not clean')
36+
return 1
3537

3638
# Ensure the -site checkout is up-to-date
3739
subprocess.check_call(['git', 'fetch', 'origin'], cwd=site_out)
@@ -40,6 +42,10 @@ def main(args):
4042
# Build and install the docs
4143
subprocess.check_call(['make', 'install', f'EMSCRIPTEN_SITE={site_out}'], cwd=site_dir)
4244

45+
if is_git_clean(site_out):
46+
print('docs are up-to-date; no changes found')
47+
return 0
48+
4349
# Create a new branch and commit the changes.
4450
subprocess.check_call(['git', 'checkout', '-b', 'update'], cwd=site_out)
4551
subprocess.check_call(['git', 'add', '.'], cwd=site_out)
@@ -48,6 +54,7 @@ def main(args):
4854
message = 'Update emscripten website\n\n'
4955
message += f'These docs were generated based on git revision {hash}'
5056
subprocess.run(['git', 'commit', '-F', '-'], input=message, text=True, cwd=site_out)
57+
return 2
5158

5259

5360
if __name__ == '__main__':

0 commit comments

Comments
 (0)