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
2 changes: 1 addition & 1 deletion .github/workflows/rebaseline-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ jobs:
fi
fi
git push origin rebaseline_tests
gh pr create --fill --base ${{ github.ref_name }}
gh pr create --fill --base ${{ github.ref_name }} --reviewer sbc100,kripken
gh pr merge --squash --auto
50 changes: 50 additions & 0 deletions .github/workflows/update-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Update website

on:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
on:
on:
workflow_dispatch

push:
branches: [ main ]

jobs:
update-website:
name: Update website
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think we need to add this token to the emscripten-site repo in order to open PRs there?

@dschuff @kripken

Copy link
Member

Choose a reason for hiding this comment

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

If the emscripten-site repo will accept PRs from any random person on github, then I don't see why emscripten-bot should be different. If we need to give emscripten-bot some permission to let CI on the site run, we could do that. But it shouldn't require actually putting the bot's token in the repo as a secret. That would only be needed if we want something to run as the bot.

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Checkout website repo
uses: actions/checkout@v4
with:
repository: kripken/emscripten-site
ref: gh-pages
path: ../emscripten-site
- 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
if ./tools/maint/update_docs.py; then
echo "rebaseline_tests returned zero, expectations up-to-date"
# Exit early and don't create a PR
exit 0
else
code=$?
if [[ $code != 2 ]] ; then
echo "rebaseline_docs.py failed with unexpected error $code (expected 2)"
exit 1
fi
fi
# Create a PR against the emscripten-site repo
cd ../emscripten-site
git push origin update
gh pr create --fill --base gh-pages --reviewer sbc100,kripken
gh pr merge --squash --auto
19 changes: 13 additions & 6 deletions tools/maint/update_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
site_dir = os.path.join(root_dir, 'site')


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


def main(args):
Expand All @@ -30,8 +28,12 @@ def main(args):

assert os.path.isdir(site_out)
print(f'Updating docs in: {site_out}')
check_git_clean(site_out)
check_git_clean(root_dir)
if not is_git_clean(site_out):
print(f'{site_out}: tree is not clean')
return 1
if not is_git_clean(root_dir):
print(f'{root_dir}: tree is not clean')
return 1

# Ensure the -site checkout is up-to-date
subprocess.check_call(['git', 'fetch', 'origin'], cwd=site_out)
Expand All @@ -40,6 +42,10 @@ 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):
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)
Expand All @@ -48,6 +54,7 @@ def main(args):
message = 'Update emscripten website\n\n'
message += f'These docs were generated based on git revision {hash}'
subprocess.run(['git', 'commit', '-F', '-'], input=message, text=True, cwd=site_out)
return 2


if __name__ == '__main__':
Expand Down