forked from googleapis/google-cloud-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstage_sites.py
More file actions
56 lines (45 loc) · 1.99 KB
/
stage_sites.py
File metadata and controls
56 lines (45 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This scripts creates sites for `google-cloud-clients` and `google-api-grpc`
# modules and commits (but does not push) them to gh-pages branch of
# GoogleCloudPlatform/google-cloud-java github repository.
# Usage:
# python utilities/stage_sites.py
import subprocess
import sys
def stage_sites(sites, gh_pages, git_url, top_site_url):
_run(['git', 'clone', '--branch', 'gh-pages', '--single-branch', git_url,
gh_pages])
_run(['mkdir', '-p', gh_pages])
for site in sites:
_create_site(site, gh_pages, top_site_url)
_run(['git', 'add', '.'], gh_pages)
_run(['git', 'commit', '-m',
"Regenerate documentation for %s. [ci skip]" % ', '.join(sites)],
gh_pages)
def _create_site(site_name, gh_pages, top_site_url):
_run(['mvn', 'site'], site_name)
_run(['mvn', 'site:stage', '-q',
"-DtopSiteURL=%s/%s" % (top_site_url, site_name)],
site_name)
_run(['rm', '-rf', site_name], gh_pages)
_run(['cp', '-r', "%s/target/staging/site/%s" % (site_name, site_name),
gh_pages])
def _run(command, cwd=None):
print("\033[1;36mExecute command:\033[0m %s" % ' '.join(command))
subprocess.check_call(command, cwd=cwd, stdout=sys.stdout, stderr=sys.stderr)
if __name__ == '__main__':
stage_sites(['google-api-grpc', 'google-cloud-clients'], 'tmp_gh-pages',
'https://github.com/GoogleCloudPlatform/google-cloud-java',
'https://googlecloudplatform.github.io/google-cloud-java')