Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding further instructions for GitHub pages docs deployment in hook #404

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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
32 changes: 28 additions & 4 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
_EXIT_SUCCESS = 0


def main(initialise_git_repository: str) -> int:
def main(initialise_git_repository: str, deploy_docs_to_github_pages: str) -> int:
"""
Create a git repository on generation of the project.

Args:
initialise_git_repository: Whether to initialise the repo
deploy_docs_to_github_pages: Whether to deploy built docs to GitHub Pages

Returns:
The return code of the process
Expand Down Expand Up @@ -65,7 +66,7 @@ def main(initialise_git_repository: str) -> int:
"-d '{{cookiecutter.project_short_description}}' "
"--public "
"-r origin "
"--source {{cookiecutter.project_slug}}"
"--source {{cookiecutter.project_slug}}\n"
)
except FileNotFoundError:
# GitHub CLI isn't installed
Expand All @@ -77,15 +78,38 @@ def main(initialise_git_repository: str) -> int:
"https://docs.github.com/en/get-started/quickstart/create-a-repo.\n\n"
"Then run:\n\n"
"git remote add origin git@github.com:"
"{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}.git"
"{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}.git\n"
)
except subprocess.CalledProcessError as e:
# some other error
print(f"There was an error with the GitHub CLI: {e.returncode}\n{e.stderr}")
return _EXIT_FAILURE
if deploy_docs_to_github_pages == "True":
print(
"The 'Documentation' GitHub Actions workflow has been set up to push the "
"built HTML documentation to a branch gh-pages on pushes to main for "
"deploying as a GitHub Pages website. To allow the GitHub Actions bot to "
"push to the gh-pages branch you need to enable 'Read and write "
"permissions' under 'Workflow permissions' at\n\n"
"https://github.com/{{cookiecutter.github_username}}/"
"{{cookiecutter.project_slug}}/settings/actions\n\n"
"After the 'Documentation' workflow has successfully completed at least "
"once you will also need to configure the repository to deploy a GitHub "
"pages site from the content on the gh-pages branch by going to\n\n"
"https://github.com/{{cookiecutter.github_username}}/"
"{{cookiecutter.project_slug}}/settings/pages\n\n"
"and under 'Built and deployment' selecting 'Deploy from a branch' for "
"the 'Source' drop-down and 'gh-pages' for the 'Branch' drop-down, "
"leaving the branch path drop-down with its default value of '/ (root)'."
Copy link
Member

Choose a reason for hiding this comment

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

Looks clear to me!

)

return _EXIT_SUCCESS


if __name__ == "__main__":
sys.exit(main("{{ cookiecutter.initialise_git_repository }}"))
sys.exit(
main(
"{{ cookiecutter.initialise_git_repository }}",
"{{ cookiecutter.deploy_docs_to_github_pages }}",
)
)