This is an example how to update statuses for GitHub pull requests using ASP.NET Core, jshint and Google Cloud.
If you have any issues or questions - feel free to create an issue.
- VSCode (Optional)
- NET Core - tested on MacOS (1.0.0-preview2-003131)
- NodeJS, npm, jshint
- GIT
- Docker
- Google Cloud SDK
- Clone repository
- Set path to git 'GitPath' in tasks.json and/or in Env variables
- Generate Personal Access Token in GitHub (enable repo scope). Set 'GitHubToken' in tasks.json and dockerfile
- Feel free to update 'GitHubName' and 'GitHubUrl' (optional)
- Windows Users: you will need to execute cmd instead of bash - TODO
cd
to theproject root/src
- Restore dependencies
dotnet restore
- Build project
dotnet build
- Run
dotnet run
- app started (http://localhost:5000)
cd
to theproject root
- Build image
docker build -t mycontainer:v1 .
- Run
docker run -i -p 8181:8181 -t mycontainer:v1
- app started (http://localhost:8181)
- Create project, Enable Billing (free trial available), Set Default Credentials
- Let's say project id 'myproject', docker image name 'gcr.io/myproject/mycontainer:v1', cluster name 'mycluster'. Google App credentials path is correct
GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_FILE
. - Install kubernetes
gcloud components install kubectl
- Build image for cloud
docker build -t gcr.io/myproject/mycontainer:v1 .
- Push it to Google Container Registry
gcloud docker push gcr.io/myproject/mycontainer:v1
- Set the Project
gcloud config set project myproject
- Create a cluster
gcloud container clusters create mycluster --num-nodes 1 --machine-type n1-standard-1 --zone europe-west1-b
- Configure command line access to the cluster
gcloud container clusters get-credentials mycluster --zone europe-west1-b
- Create deployment from image
kubectl run github --image=gcr.io/myproject/mycontainer:v1 --port=8181
- Make sure the deployment and pod are running
kubectl get deployments
+kubectl get pods
- Expose deployment to the outside world
kubectl expose deployment github --type="LoadBalancer"
- Get external IP address
kubectl get services
- app started (use your external IP)
- Create GitHub account
- Create new GitHub integration
- Use any name, url: 'http://external_ip_from_cloud:8181/Home/Webhook', enable 'Commit statuses' (Permissions & events)
- Create a repo for tests
- Add integration for test repository: repo_url/settings/installations
- Enable protected branches and status checks from your integration: repo_url/settings/branches
- Create PR in test repository, that's it! Examples.
- .NET Core: https://www.microsoft.com/net/core
- ASP.NET Core: https://docs.asp.net/en/latest/intro.html
- Docker: https://www.docker.com/
- Google Cloud: https://cloud.google.com/
- Kubernetes: http://kubernetes.io/
- .NET on Google Cloud Platform: https://cloud.google.com/dotnet/docs/
- GitHub Integrations: https://github.com/integrations
- GitHub Developer: https://developer.github.com