Skip to content

Latest commit

 

History

History
66 lines (56 loc) · 4.07 KB

README.md

File metadata and controls

66 lines (56 loc) · 4.07 KB

Create status checks in GitHub

This is an example how to update statuses for GitHub pull requests using ASP.NET Core, jshint and Google Cloud.

Example

If you have any issues or questions - feel free to create an issue.

Requirements

Before you start

Getting started (locally)

  1. cd to the project root/src
  2. Restore dependencies dotnet restore
  3. Build project dotnet build
  4. Run dotnet run - app started (http://localhost:5000)

Getting started (docker)

  1. cd to the project root
  2. Build image docker build -t mycontainer:v1 .
  3. Run docker run -i -p 8181:8181 -t mycontainer:v1 - app started (http://localhost:8181)

Getting started (cloud)

  1. Create project, Enable Billing (free trial available), Set Default Credentials
  2. 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.
  3. Install kubernetes gcloud components install kubectl
  4. Build image for cloud docker build -t gcr.io/myproject/mycontainer:v1 .
  5. Push it to Google Container Registry gcloud docker push gcr.io/myproject/mycontainer:v1
  6. Set the Project gcloud config set project myproject
  7. Create a cluster gcloud container clusters create mycluster --num-nodes 1 --machine-type n1-standard-1 --zone europe-west1-b
  8. Configure command line access to the cluster gcloud container clusters get-credentials mycluster --zone europe-west1-b
  9. Create deployment from image kubectl run github --image=gcr.io/myproject/mycontainer:v1 --port=8181
  10. Make sure the deployment and pod are running kubectl get deployments + kubectl get pods
  11. Expose deployment to the outside world kubectl expose deployment github --type="LoadBalancer"
  12. Get external IP address kubectl get services - app started (use your external IP)

GitHub Integration

  1. Create GitHub account
  2. Create new GitHub integration
  3. Use any name, url: 'http://external_ip_from_cloud:8181/Home/Webhook', enable 'Commit statuses' (Permissions & events)
  4. Create a repo for tests
  5. Add integration for test repository: repo_url/settings/installations
  6. Enable protected branches and status checks from your integration: repo_url/settings/branches
  7. Create PR in test repository, that's it! Examples.

Links

  1. .NET Core: https://www.microsoft.com/net/core
  2. ASP.NET Core: https://docs.asp.net/en/latest/intro.html
  3. Docker: https://www.docker.com/
  4. Google Cloud: https://cloud.google.com/
  5. Kubernetes: http://kubernetes.io/
  6. .NET on Google Cloud Platform: https://cloud.google.com/dotnet/docs/
  7. GitHub Integrations: https://github.com/integrations
  8. GitHub Developer: https://developer.github.com