@@ -52,6 +52,7 @@ mkdir "${REPO_DIR}" && cd "${REPO_DIR}"
5252git init && git remote add origin " ${REPO_URL} "
5353
5454# Generate a keypair
55+ echo " Generating random private SSH key"
5556ssh-keygen -b 2048 -t rsa -f " /tmp/${PACK} _rsa" -q -N " "
5657
5758# GitHub: create a repo or create an alias and move
6667fi
6768
6869# GitHub: rename the alias repo to its full name
69- echo " Renaming the repo to ${REPO_NAME} ."
70+ echo " Github: Renaming the repo to ${REPO_NAME} ."
7071curl -sS --fail -u " ${USERNAME} :${PASSWORD} " -X PATCH --header " Content-Type: application/json" \
7172-d ' {"name": "' " ${REPO_NAME} " ' "}' \
7273" https://api.github.com/repos/${EXCHANGE_ORG} /${REPO_ALIAS} "
7374
7475# GitHub: create a read-write key for the repo
76+ echo " Github: Creating a read-write key for the Github repo"
7577curl -sS --fail -u " ${USERNAME} :${PASSWORD} " -X POST --header " Content-Type: application/json" \
7678 -d ' {"title": "CircleCI read-write key", "key": "' " $( cat " /tmp/${PACK} _rsa.pub" ) " ' ", "read_only": false}' \
7779 " https://api.github.com/repos/${EXCHANGE_ORG} /${REPO_NAME} /keys"
7880
7981# GitHub: create a user-scope token
82+ echo " Github: Creating a Github user-scoped token"
8083curl -sS --fail -u " ${USERNAME} :${PASSWORD} " -X POST --header " Content-Type: application/json" \
8184 -d ' {"scopes": ["public_repo"], "note": "CircleCI: ' " ${REPO_NAME} " ' "}' \
8285 " https://api.github.com/authorizations" | jq " .token" > " /tmp/${PACK} _user_token"
@@ -102,27 +105,32 @@ git commit -m "Bootstrap a StackStorm Exchange pack repository for pack ${PACK}.
102105git push origin master
103106
104107# Github: Configure webhook to send notifications to our Slack instance on changes
108+ echo " Github: Configuring Github to send webhook notifications to our Slack"
105109curl -sS --fail -u " ${USERNAME} :${PASSWORD} " -X POST --header " Content-Type: application/json" \
106110 -d ' {"name": "web", "active": true, "config": {"url": "' " ${SLACK_WEBHOOK_URL} " ' ", "content_type": "application/json"}, "events": ["commit_comment", "issue_comment", "issues", "pull_request", "pull_request_review", "pull_request_review_comment"]}' \
107111 " https://api.github.com/repos/${EXCHANGE_ORG} /${REPO_NAME} /hooks"
108112
109113# Github: If second Slack webhook URL set (e.g. for community), configure that to notify on changes
110114if [[ ! -z $SLACK_WEBHOOK_URL_COMMUNITY ]];
111115then
116+ echo " Github: Configuring Github to send webhook notifications to our community Slack"
112117 curl -sS --fail -u " ${USERNAME} :${PASSWORD} " -X POST --header " Content-Type: application/json" \
113118 -d ' {"name": "web", "active": true, "config": {"url": "' " ${SLACK_WEBHOOK_URL_COMMUNITY} " ' ", "content_type": "application/json"}, "events": ["issues", "pull_request"]}' \
114119 " https://api.github.com/repos/${EXCHANGE_ORG} /${REPO_NAME} /hooks"
115120fi
116121
117122# CircleCI: follow the project
123+ echo " CircleCI: Following the project"
118124curl -sS --fail -X POST " https://circleci.com/api/v1.1/project/github/${EXCHANGE_ORG} /${REPO_NAME} /follow?circle-token=${CIRCLECI_TOKEN} "
119125
120126# CircleCI: upload the read-write key
127+ echo " CircleCI: Adding read-write SSH key"
121128curl -sS --fail -X POST --header " Content-Type: application/json" \
122129 -d ' {"hostname":"github.com","private_key":"' " $( cat " /tmp/${PACK} _rsa" ) " ' "}' \
123130 " https://circleci.com/api/v1.1/project/github/${EXCHANGE_ORG} /${REPO_NAME} /ssh-key?circle-token=${CIRCLECI_TOKEN} "
124131
125132# CircleCI: specify the credentials (the machine login and the new user-scope token)
133+ echo " CircleCI: Setting credentials (machine login and user-scoped token)"
126134curl -sS --fail -X POST --header " Content-Type: application/json" \
127135 -d ' {"name":"MACHINE_USER", "value":"' " ${USERNAME} " ' "}' \
128136 " https://circleci.com/api/v1.1/project/github/${EXCHANGE_ORG} /${REPO_NAME} /envvar?circle-token=${CIRCLECI_TOKEN} "
@@ -131,13 +139,15 @@ curl -sS --fail -X POST --header "Content-Type: application/json" \
131139 " https://circleci.com/api/v1.1/project/github/${EXCHANGE_ORG} /${REPO_NAME} /envvar?circle-token=${CIRCLECI_TOKEN} "
132140
133141# CircleCI: Enable builds for pull requests from forks
142+ echo " CircleCI: Enabling builds for pull requests from forks"
134143curl -sS --fail -X PUT --header " Content-Type: application/json" \
135144 -d ' {"feature_flags":{"build-fork-prs":true}}' \
136145 " https://circleci.com/api/v1.1/project/github/${EXCHANGE_ORG} /${REPO_NAME} /settings?circle-token=${CIRCLECI_TOKEN} "
137146
138147# CircleCI has started automatically adding a read-only deploy key when following a project
139148# This breaks our deployment process.
140149# So we need to get a list of read-only keys, and delete them
150+ echo " CircleCI: Remove read-only keys."
141151RO_KEYS=$( curl -sS --fail -u " ${USERNAME} :${PASSWORD} " -X GET \
142152 " https://api.github.com/repos/${EXCHANGE_ORG} /${REPO_NAME} /keys" | jq -r ' .[]| select(.read_only == true) | [.id]| @sh' )
143153
0 commit comments