We use AWS code deploy to deploy the Github projects to Ec2 instances every time it deploys it asks for Github username and password to download the repository. Found following ways to solve this
Setting up Oauth for PHP repository was done by adding it in composer auth.json .composer/auth.json.
{
"http-basic": {},
"github-oauth": {"github.com": "xyzasasasauhu"}
}
But couldn't find a way to do this for Golang project. Typically we want to achieve go get https://github.com/username/reponame without supplying the credentials explicitly.
In the top right corner of GitHub.com, click your profile photo, then click Your organizations. Next to the organization, click Settings. In the "Integrations" section of the sidebar, click Third-party access. Under "Third-party application access policy," click Setup application access restrictions.
GitHub's OAuth implementation supports the standard authorization code grant type and the OAuth 2.0 Device Authorization Grant for apps that don't have access to a web browser. If you want to skip authorizing your app in the standard way, such as when testing your app, you can use the non-web application flow.
There are two solutions to this problem:
Don't use go get
to get the code for your private GitHub repo. As long as the code ends up in the correct subdirectory ($GOPATH/src/github.com/org/project
), Go doesn't care how it got there. Simply add to your build script a few commands:
DIR=$GOPATH/src/github.com/org/project
TOKEN=yourtoken
if [ -d $DIR ]; then
cd $DIR
git reset --hard
git clean -dfx
else
mkdir -p $DIR
cd $DIR
git init
fi
git pull https://[email protected]/org/project.git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With