Skip to content

Commit de1310e

Browse files
authored
[CI] Fix update-website.yml (emscripten-core#25796)
- Ignore changes that only include AUTHORS.html - Use EMSCRIPTEN_BOT_TOKEN when checking out the `-site` repo since we need that in order to push to it - Move `-site` repo checkout to within the emscripten checkout.
1 parent bfe724f commit de1310e

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

.github/workflows/update-website.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Update website
1111
runs-on: ubuntu-latest
1212
env:
13-
GH_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
13+
GITHUB_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
1414
steps:
1515
- name: Checkout repo
1616
uses: actions/checkout@v4
@@ -23,16 +23,18 @@ jobs:
2323
repository: kripken/emscripten-site
2424
ref: gh-pages
2525
path: site/emscripten-site
26+
token: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
2627
- name: pip install
2728
run: |
2829
which python3
2930
python3 --version
3031
python3 -m pip install -r requirements-dev.txt
3132
- name: Update docs
3233
run: |
33-
git config user.name emscripten-bot
34-
git config user.email [email protected]
35-
./bootstrap
34+
set -o errexit
35+
set -o xtrace
36+
git config --global user.name emscripten-bot
37+
git config --global user.email [email protected]
3638
if ./tools/maint/update_docs.py; then
3739
echo "rebaseline_tests returned zero, expectations up-to-date"
3840
# Exit early and don't create a PR
@@ -46,6 +48,8 @@ jobs:
4648
fi
4749
# Create a PR against the emscripten-site repo
4850
cd site/emscripten-site
49-
git push origin update
50-
gh pr create --fill --base gh-pages --reviewer sbc100,kripken
51-
gh pr merge --squash --auto
51+
git push -f origin update
52+
gh pr create --fill --head update --base gh-pages --reviewer sbc100,kripken
53+
# TODO: add --auto here once we have the review requirment in place
54+
# for PR to the -site repo
55+
gh pr merge --squash # --auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ coverage.xml
3030
# Test output
3131
/out/
3232

33+
# When updating the website we check it out here.
34+
/site/emscripten-site/
35+
3336
# Windows ps1 launchers (created by ./tools/maint/create_entry_points.py)
3437
*.ps1
3538
# ...except the templates.

tools/maint/update_docs.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,24 @@
1515
root_dir = os.path.dirname(os.path.dirname(script_dir))
1616
site_dir = os.path.join(root_dir, 'site')
1717

18+
message_template = '''\
19+
Automatic update of the emscripten website
20+
21+
This is an automated change generated by `tools/maint/update_docs.py` in the emscripten repo.
22+
23+
The change was generated at git revision https://github.com/emscripten-core/emscripten/commit/%s
24+
'''
25+
1826

1927
def is_git_clean(dirname):
2028
return subprocess.check_output(['git', 'status', '-uno', '--porcelain'], text=True, cwd=dirname).strip() == ''
2129

2230

31+
def get_changed_files(dirname):
32+
files_changed = subprocess.check_output(['git', 'status', '-uno', '--porcelain'], text=True, cwd=dirname).splitlines()
33+
return [line[3:].strip() for line in files_changed]
34+
35+
2336
def main(args):
2437
if args:
2538
site_out = args[0]
@@ -42,17 +55,21 @@ def main(args):
4255
# Build and install the docs
4356
subprocess.check_call(['make', 'install', f'EMSCRIPTEN_SITE={site_out}'], cwd=site_dir)
4457

45-
if is_git_clean(site_out):
58+
files_changed = get_changed_files(site_dir)
59+
# This AUTHORS.html file happens to always contains the current date, so we don't want
60+
# to consider updates that contain only this one file
61+
if 'docs/contributing/AUTHORS.html' in files_changed:
62+
files_changed.remove('docs/contributing/AUTHORS.html')
63+
64+
if not files_changed:
4665
print('docs are up-to-date; no changes found')
4766
return 0
4867

4968
# Create a new branch and commit the changes.
5069
subprocess.check_call(['git', 'checkout', '-b', 'update'], cwd=site_out)
5170
subprocess.check_call(['git', 'add', '.'], cwd=site_out)
52-
5371
hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], text=True, cwd=root_dir).strip()
54-
message = 'Update emscripten website\n\n'
55-
message += f'These docs were generated based on git revision {hash}'
72+
message = message_template % hash
5673
subprocess.run(['git', 'commit', '-F', '-'], input=message, text=True, cwd=site_out)
5774
return 2
5875

0 commit comments

Comments
 (0)