Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/update-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Update website
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that this doesn't actually matter; gh respects both for some reason.

steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -23,16 +23,18 @@ jobs:
repository: kripken/emscripten-site
ref: gh-pages
path: site/emscripten-site
token: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
- name: pip install
run: |
which python3
python3 --version
python3 -m pip install -r requirements-dev.txt
- name: Update docs
run: |
git config user.name emscripten-bot
git config user.email emscripten-bot@users.noreply.github.com
./bootstrap
set -o errexit
set -o xtrace
git config --global user.name emscripten-bot
git config --global user.email emscripten-bot@users.noreply.github.com
if ./tools/maint/update_docs.py; then
echo "rebaseline_tests returned zero, expectations up-to-date"
# Exit early and don't create a PR
Expand All @@ -46,6 +48,8 @@ jobs:
fi
# Create a PR against the emscripten-site repo
cd site/emscripten-site
git push origin update
gh pr create --fill --base gh-pages --reviewer sbc100,kripken
gh pr merge --squash --auto
git push -f origin update
gh pr create --fill --head update --base gh-pages --reviewer sbc100,kripken
# TODO: add --auto here once we have the review requirment in place
# for PR to the -site repo
gh pr merge --squash # --auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ coverage.xml
# Test output
/out/

# When updating the website we check it out here.
/site/emscripten-site/

# Windows ps1 launchers (created by ./tools/maint/create_entry_points.py)
*.ps1
# ...except the templates.
Expand Down
25 changes: 21 additions & 4 deletions tools/maint/update_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,24 @@
root_dir = os.path.dirname(os.path.dirname(script_dir))
site_dir = os.path.join(root_dir, 'site')

message_template = '''\
Automatic update of the emscripten website

This is an automated change generated by `tools/maint/update_docs.py` in the emscripten repo.

The change was generated at git revision https://github.com/emscripten-core/emscripten/commit/%s
'''


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


def get_changed_files(dirname):
files_changed = subprocess.check_output(['git', 'status', '-uno', '--porcelain'], text=True, cwd=dirname).splitlines()
return [line[3:].strip() for line in files_changed]


def main(args):
if args:
site_out = args[0]
Expand All @@ -42,17 +55,21 @@ def main(args):
# Build and install the docs
subprocess.check_call(['make', 'install', f'EMSCRIPTEN_SITE={site_out}'], cwd=site_dir)

if is_git_clean(site_out):
files_changed = get_changed_files(site_dir)
# This AUTHORS.html file happens to always contains the current date, so we don't want
# to consider updates that contain only this one file
if 'docs/contributing/AUTHORS.html' in files_changed:
files_changed.remove('docs/contributing/AUTHORS.html')

if not files_changed:
print('docs are up-to-date; no changes found')
return 0

# Create a new branch and commit the changes.
subprocess.check_call(['git', 'checkout', '-b', 'update'], cwd=site_out)
subprocess.check_call(['git', 'add', '.'], cwd=site_out)

hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], text=True, cwd=root_dir).strip()
message = 'Update emscripten website\n\n'
message += f'These docs were generated based on git revision {hash}'
message = message_template % hash
subprocess.run(['git', 'commit', '-F', '-'], input=message, text=True, cwd=site_out)
return 2

Expand Down
Loading