Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
47 changes: 27 additions & 20 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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"

Expand Down Expand Up @@ -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(
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion create-an-organization-webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion create-webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions dotcom-configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
43 changes: 23 additions & 20 deletions the-power-dotcom.skeleton
Original file line number Diff line number Diff line change
Expand Up @@ -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="<a webhook url>"
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
Expand Down
Loading