diff --git a/.github/workflows/rebaseline-tests.yml b/.github/workflows/rebaseline-tests.yml index 1ab74047a347a..82f87e9a5a82d 100644 --- a/.github/workflows/rebaseline-tests.yml +++ b/.github/workflows/rebaseline-tests.yml @@ -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 diff --git a/.github/workflows/update-website.yml b/.github/workflows/update-website.yml new file mode 100644 index 0000000000000..eda6afc843512 --- /dev/null +++ b/.github/workflows/update-website.yml @@ -0,0 +1,50 @@ +name: Update website + +on: + push: + branches: [ main ] + +jobs: + update-website: + name: Update website + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} + 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 diff --git a/tools/maint/update_docs.py b/tools/maint/update_docs.py index 6d9cfd0b6db9f..bf6337f06c657 100755 --- a/tools/maint/update_docs.py +++ b/tools/maint/update_docs.py @@ -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): @@ -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) @@ -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) @@ -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__':