-
Notifications
You must be signed in to change notification settings - Fork 2
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
replace master references with default branch name fetched from github api #141
base: master
Are you sure you want to change the base?
replace master references with default branch name fetched from github api #141
Conversation
Tagging security since this also adds new credentials to the CI pipeline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments
if [[ $BRANCH != "master" ]]; then | ||
: ${CIRCLE_PROJECT_REPONAME?"Missing required env var"} | ||
REPO=$CIRCLE_PROJECT_REPONAME | ||
: ${GITHUB_TOKEN?"Missing required env var"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this token need to be added and rotated in all CI projects?
DEFAULT_BRANCH=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/repos/Clever/$REPO" | jq -r '.default_branch') | ||
|
||
if [[ $BRANCH != $DEFAULT_BRANCH ]]; then | ||
echo "Skipping sync for non-master branch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text here should also get updated, so that if the primary branch is ever named main
this error message wouldn't be confusing.
@@ -14,7 +16,7 @@ echo "2) Run the following command, replacing CIRCLE_API_TOKEN with the token fr | |||
echo "curl -u CIRCLE_API_TOKEN: \\ | |||
-X POST \\ | |||
--header \"Content-Type: application/json\" -d '{ | |||
\"branch\": \"master\", | |||
\"branch\": \"${DEFAULT_BRANCH}\", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the plan to accompany this with catapult changes? This would probably not behave as expected with just the CI changes if a team were to change their primary branch name.
Jira
https://clever.atlassian.net/browse/DD-5739
Overview
Testing changes to no longer reference master in favor of referencing the default branch returned from the github API.
Testing
Default branch correctly outputs master for the ci-scripts repo
Rollout