-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR improves the initial docs deploy job that was introduced in PR: #342 Add script for the docs deployment - For pre-release, deploy at `dev` - For release, deploy at version - For PR, deploy at `dev`
- Loading branch information
1 parent
3ec3303
commit 90941ae
Showing
4 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import subprocess | ||
import sys | ||
|
||
from packaging import version | ||
|
||
import dagfactory | ||
|
||
|
||
def deploy_docs(deploy_type: str): | ||
_version = version.parse(dagfactory.__version__) | ||
|
||
set_default = False | ||
|
||
if deploy_type == "release": | ||
if _version.pre is not None: | ||
command = ["mike", "deploy", "--push", "dev"] | ||
else: | ||
command = ["mike", "deploy", "--push", "--update-aliases", str(_version), "latest"] | ||
set_default = True | ||
else: | ||
command = ["mike", "deploy", "--push", "dev"] | ||
|
||
try: | ||
subprocess.run(command, capture_output=True, text=True, check=True) | ||
if set_default: | ||
default_command = ["mike", "set-default", "latest"] | ||
subprocess.run(default_command, capture_output=True, text=True, check=True) | ||
except subprocess.CalledProcessError as e: | ||
raise Exception(f"Error deploying: {e.stderr}") | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 2: | ||
raise Exception("Argument deploy type is required: 'dev' or 'release'") | ||
|
||
deploy_type = sys.argv[1] | ||
|
||
if deploy_type not in ["dev", "release"]: | ||
raise Exception("Invalid argument provided. Valid deploy types are 'dev' or 'release'.") | ||
|
||
deploy_docs(deploy_type) |