Skip to content

Commit 0a40327

Browse files
authored
Merge pull request #58 from StackStorm-Exchange/delete_ro_key
Auto-remove CircleCI read-only key
2 parents 9c31798 + 51d7a5f commit 0a40327

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

utils/exchange-bootstrap.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,16 @@ curl -sS --fail -X PUT --header "Content-Type: application/json" \
135135
-d '{"feature_flags":{"build-fork-prs":true}}' \
136136
"https://circleci.com/api/v1.1/project/github/${EXCHANGE_ORG}/${REPO_NAME}/settings?circle-token=${CIRCLECI_TOKEN}"
137137

138+
# CircleCI has started automatically adding a read-only deploy key when following a project
139+
# This breaks our deployment process.
140+
# So we need to get a list of read-only keys, and delete them
141+
RO_KEYS=$(curl -sS --fail -u "${USERNAME}:${PASSWORD}" -X GET \
142+
"https://api.github.com/repos/${EXCHANGE_ORG}/${REPO_NAME}/keys" | jq -r '.[]| select(.read_only == true) | [.id]| @sh')
143+
144+
for RO_KEY in ${RO_KEYS};
145+
do
146+
curl -sS --fail -u "${USERNAME}:${PASSWORD}" -X DELETE "https://api.github.com/repos/${EXCHANGE_ORG}/${REPO_NAME}/keys/${RO_KEY}"
147+
done
148+
138149
# Clean up
139150
rm -rf "${REPO_DIR}" "/tmp/${PACK}_rsa*" "/tmp/${PACK}_user_token"

0 commit comments

Comments
 (0)