diff --git a/configure.py b/configure.py index 8e916a2b..5161d5b9 100755 --- a/configure.py +++ b/configure.py @@ -91,6 +91,7 @@ def main(args): # https://docs.github.com/en/organizations org="${org}" owner="${org}" +org_webhook_url=${org_webhook_url} org_secret_name="PWR_ORG_SECRET_001" org_owner="${org_owner}" org_members="${org_members}" @@ -107,7 +108,7 @@ def main(args): repo_secret_name="REPOSITORY_SECRET_001" repo_secret_value="repository_secret_string" # webhook url is also used by the organization -webhook_url=${webhook_url} +repo_webhook_url=${repo_webhook_url} repo_webhook_secret="pwr-repo-webhook-secret" has_issues=true has_wiki=true @@ -254,6 +255,7 @@ def main(args): # private_pem_file=/opt/the-power/testapp.YYYY-MM-DD.private-key.pem # #=> The absolute path of the pem file is /opt/the-power/Downloads/testapp.YYYY-MM-DD.private-key.pem # +app_configure=${app_configure} app_private_pem=${app_private_pem} # When working with the power in a codespace you may need a path like: #private_pem_file=../../workspaces/the-power/ft-testapp.2022-03-23.private-key.pem @@ -426,7 +428,7 @@ def main(args): args.org = input(f"Enter Org name: ") # If configuring a GitHub App: - if args.configure_github_app != "no": + if args.app_configure != "no": if args.app_id != "": logger.info(f"default_app_id = {args.app_id}") else: @@ -453,22 +455,22 @@ def main(args): f"Enter path relative from home to app private key: " ) - if args.webhook_url == "smee": - webhook_url = thepower.get_webhook_url() - if webhook_url is None: - webhook_url = input(f"Enter webhook URL: ") + if args.repo_webhook_url == "smee": + repo_webhook_url = thepower.get_webhook_url() + if repo_webhook_url is None: + repo_webhook_url = input(f"Enter webhook URL: ") - args.webhook_url = webhook_url - if re.match(r"^https?://", args.webhook_url): - thepower.open_webhook_url_in_browser(args.webhook_url) + args.repo_webhook_url = repo_webhook_url + if re.match(r"^https?://", args.repo_webhook_url): + thepower.open_webhook_url_in_browser(args.repo_webhook_url) else: logger.info( "No webhook URL supplied. You can still set a webhook URL in .gh-api-examples.conf file." ) - elif args.webhook_url: - logger.info(f"Webhook URL = {args.webhook_url}") + elif args.repo_webhook_url: + logger.info(f"Webhook URL = {args.repo_webhook_url}") else: - args.webhook_url = input(f"Enter webhook url: ") + args.repo_webhook_url = input(f"Enter webhook url: ") out_filename = ".gh-api-examples.conf" @@ -503,7 +505,7 @@ def main(args): parser.add_argument( "--app-configure", action="store", - dest="configure_github_app", + dest="app_configure", default="no", ) parser.add_argument( @@ -517,7 +519,7 @@ def main(args): action="store", dest="app_id", default="1", - help="an app id (integer)", + help="an app id" , ) parser.add_argument( "--app-installation-id", @@ -562,12 +564,18 @@ def main(args): "--mgmt-port", action="store", dest="mgmt_port", default=8443 ) parser.add_argument( - "-w", - "--webhook-url", + "--repo-webhook-url", action="store", - dest="webhook_url", + dest="repo_webhook_url", default="smee", - help="Set this if you want to provide your own webhook url.", + help="Set this if you want to provide your own webhook url for a repository.", + ) + parser.add_argument( + "--org_webhook-url", + action="store", + dest="org_webhook_url", + default="https://example.com/webhook", + help="Set this if you want to provide your own webhook url for a repository.", ) parser.add_argument( "--x-client-id", @@ -620,8 +628,7 @@ def main(args): help="Set this for github.com config", ) parser.add_argument( - "-r", - "--repo-name", + "--repo", action="store", dest="repo_name", default="testrepo", diff --git a/create-an-organization-webhook.sh b/create-an-organization-webhook.sh index 92a063a6..4ae74832 100755 --- a/create-an-organization-webhook.sh +++ b/create-an-organization-webhook.sh @@ -13,7 +13,7 @@ fi json_file=tmp/create-an-organization-webhook.json jq -n \ --arg name "web" \ - --arg webhook_url "${webhook_url}" \ + --arg webhook_url "${org_webhook_url}" \ --arg ct "json" \ '{ name: $name, diff --git a/create-webhook.sh b/create-webhook.sh index 971b9060..2baab7fe 100755 --- a/create-webhook.sh +++ b/create-webhook.sh @@ -14,10 +14,11 @@ if [ -z "$1" ] repo=$1 fi + json_file=tmp/create-a-repository-webhook.json jq -n \ --arg name "web" \ - --arg webhook_url "${webhook_url}" \ + --arg webhook_url "${repo_webhook_url}" \ --arg ct "json" \ '{ name: $name, diff --git a/dotcom-configure.sh b/dotcom-configure.sh index f459af60..bcc7bc7a 100755 --- a/dotcom-configure.sh +++ b/dotcom-configure.sh @@ -19,10 +19,10 @@ python3 configure.py --hostname "${hostname}" \ --enterprise-name "${enterprise_name}" \ --org "${org}" \ --repo "${repo}" \ + --repo-webhook-url "${repo_webhook_url}" \ --default-repo-visibility ${default_repo_visibility:-private} \ --token "${github_token}" \ - --webhook-url "${webhook}" \ - --app-configure ${app_configure} \ + --app-configure ${app_configure:-no} \ --app-id "${app_id}" \ --app-client-secret "${app_client_secret:-an_app_client_secret}" \ --app-installation-id "${app_installation_id:-an_app_installation_id}" \ diff --git a/the-power-dotcom.skeleton b/the-power-dotcom.skeleton index a34939d7..964f9443 100755 --- a/the-power-dotcom.skeleton +++ b/the-power-dotcom.skeleton @@ -9,51 +9,54 @@ # hostname="api.github.com" -github_token="_a-github-token_" +github_token="ghp_a_real_github_token_placed_here_____" -enterprise_name="_an-enterprise-name_" -org="an_org_name" +enterprise_name="_an_enterprise-name_" + +# Organization +org="_an_org_name_" +org_webhook_url="smee" # Repository repo="testrepo" -repo_webhook="" +repo_webhook_url="smee" repo_visibility="private" # Team -team_members="_space separated list of github usernames_" -team_admin="_github username of team admin_" +team_members="_space_separated_list_of_github_usernames_" +team_admin="_github_username_of_team_admin_" -default_committer="_github username of a default committer_" +default_committer="_github_username_of_a_default_committer_" # Pull Request pr_approver_token="_a_fine_grained_PAT_" pr_approver_name="_a_github_username_" # GitHub App -app_name"_an app name_" -app_id="_an app id_" -app_installation_id="_an app installation id_" -app_client_id="_an app client id_" -app_client_secret="_an app client secret_" +app_configure="no" +app_name="_an_app_name_" +app_id="_an_app_id_" +app_installation_id="_an_app_installation_id_" +app_client_id="_an_app_client_id_" +app_client_secret="_an_app_client_secret_" app_private_pem="~/Downloads/app_name.YYYY-MM-DD.private-key.pem" # Enterprise GitHub App -ent_github_app_name="_an enterprise app name_" -ent_app_id="_an app id integer_" +ent_github_app_name="_an_enterprise_app_name_" +ent_app_id="_an_app_id_" ent_app_client_id="_ent_app_client_id_" ent_app_public_link="https://example.com/ent-app01-public-link" -ent_app_client_secret="_an ent_app_client_secret_" +ent_app_client_secret="_an_ent_app_client_secret_" ent_app_private_pem="~/Downloads/ent-app01.2025-02-12.private-key.pem" -ent_app_installation_id="_an enterprise installation id (integer)_" +ent_app_installation_id="_an_enterprise_app_installation_id" # Legacy Oauth App -x_client_id="_an oauth app client id_" -x_client_secret="_an oauth app client secret_" - -chrome_profile="_ a chrome profile number_" +x_client_id="_an_oauth_app_client_id_" +x_client_secret="_an_oauth_app_client_secret_" +chrome_profile="_a_chrome_profile_number_" # Used on GHES appliances for org creation. number_of_orgs=5