You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ti...@apache.org on 2023/01/11 08:30:00 UTC

[pulsar-site] 02/02: [fix][ci] Sync and build push to different branch names

This is an automated email from the ASF dual-hosted git repository.

tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git

commit 6694f14133ec132ce7f323471a8438e76d3667ca
Author: tison <wa...@gmail.com>
AuthorDate: Wed Jan 11 16:29:50 2023 +0800

    [fix][ci] Sync and build push to different branch names
    
    Signed-off-by: tison <wa...@gmail.com>
---
 tools/pytools/bin/site-publisher.py        | 9 +++++----
 tools/pytools/bin/site-updater.py          | 6 ++++--
 tools/pytools/lib/execute/site_uploader.py | 8 ++++----
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/tools/pytools/bin/site-publisher.py b/tools/pytools/bin/site-publisher.py
index 963a5da9b75..c13a03d0508 100755
--- a/tools/pytools/bin/site-publisher.py
+++ b/tools/pytools/bin/site-publisher.py
@@ -33,16 +33,17 @@ if __name__ == '__main__':
     args = parser.parse_args()
 
     git = find_command('git', msg="git is required")
+    branch = 'asf-site-next'
 
     with tempfile.TemporaryDirectory() as cwd:
         if args.site_path is None:
-            run(git, 'clone', '-b', 'asf-site-next', '--depth', '1', 'https://github.com/apache/pulsar-site', cwd=cwd)
+            run(git, 'clone', '-b', branch, '--depth', '1', 'https://github.com/apache/pulsar-site', cwd=cwd)
             site = Path(cwd) / 'pulsar-site'
         else:
             site = Path(args.site_path)
 
-        site_builder.execute(site)
-
         commit = run_pipe(git, 'rev-parse', '--short', 'HEAD', cwd=root_path()).read().strip()
         msg = f'Site updated at revision {commit}'
-        site_uploader.execute(args.push, msg, site)
+
+        site_builder.execute(site)
+        site_uploader.execute(args.push, msg, site, branch)
diff --git a/tools/pytools/bin/site-updater.py b/tools/pytools/bin/site-updater.py
index 8b28d55debd..354e6df3a29 100755
--- a/tools/pytools/bin/site-updater.py
+++ b/tools/pytools/bin/site-updater.py
@@ -33,14 +33,16 @@ if __name__ == '__main__':
     args = parser.parse_args()
 
     git = find_command('git', msg="git is required")
+    branch = 'master'
 
     with tempfile.TemporaryDirectory() as cwd:
         if args.master_path is None:
-            run(git, 'clone', '-b', 'master', '--depth', '1', 'https://github.com/apache/pulsar', cwd=cwd)
+            run(git, 'clone', '-b', branch, '--depth', '1', 'https://github.com/apache/pulsar', cwd=cwd)
             master = Path(cwd) / 'pulsar'
         else:
             master = Path(args.master_path)
 
         commit = run_pipe(git, 'rev-parse', '--short', 'HEAD', cwd=master).read().strip()
         msg = f'Docs sync done from apache/pulsar (#{commit})'
-        site_uploader.execute(args.push, msg, root_path())
+
+        site_uploader.execute(args.push, msg, root_path(), branch)
diff --git a/tools/pytools/lib/execute/site_uploader.py b/tools/pytools/lib/execute/site_uploader.py
index cbeea5b15a3..3317effceb4 100755
--- a/tools/pytools/lib/execute/site_uploader.py
+++ b/tools/pytools/lib/execute/site_uploader.py
@@ -43,7 +43,7 @@ def _should_push(mode: Mode) -> bool:
     return result
 
 
-def _do_push(msg: str, site: Path):
+def _do_push(msg: str, site: Path, branch: str):
     git = find_command('git', msg="git is required")
 
     run(git, 'add', '-A', '.', cwd=site)
@@ -61,12 +61,12 @@ def _do_push(msg: str, site: Path):
     changed = run_pipe(git, 'status', '--porcelain', cwd=site).read().strip()
     if len(changed) != 0:
         run(git, 'commit', '-m', msg, cwd=site)
-        run(git, 'push', 'origin', 'main', cwd=site)
+        run(git, 'push', 'origin', branch, cwd=site)
 
 
-def execute(mode: Mode, msg: str, site: Path):
+def execute(mode: Mode, msg: str, site: Path, branch: str):
     if _should_push(mode):
-        _do_push(msg, site)
+        _do_push(msg, site, branch)
     else:  # show changes
         git = find_command('git', msg="git is required")
         change_files = run_pipe(git, 'status', '--porcelain', cwd=site).read().strip()