Skip to content

Commit

Permalink
add github urls format
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Jun 10, 2019
1 parent 6dd8aad commit 015f190
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ integrations:
webhook_secret: Pz2ufk7r5BTjnkOo
# whether to use ssh or https to clone
clone_with: https
# HTTPS URL format, Full name will be something like Clivern/Rabbit
https_format: https://github.com/{$full_name}.git
# SSH URL format, Full name will be something like Clivern/Rabbit
ssh_format: [email protected]:{$full_name}.git
# Bitbucket Configs
bitbucket:
# Webhook URI (Full URL will be app.domain + webhook_uri)
Expand Down
4 changes: 4 additions & 0 deletions config.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ integrations:
webhook_secret: Pz2ufk7r5BTjnkOo
# whether to use ssh or https to clone
clone_with: https
# HTTPS URL format, Full name will be something like Clivern/Rabbit
https_format: https://github.com/{$full_name}.git
# SSH URL format, Full name will be something like Clivern/Rabbit
ssh_format: [email protected]:{$full_name}.git
# Bitbucket Configs
bitbucket:
# Webhook URI (Full URL will be app.domain + webhook_uri)
Expand Down
4 changes: 4 additions & 0 deletions deployments/docker-compose/configs/config.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ integrations:
webhook_secret: Pz2ufk7r5BTjnkOo
# whether to use ssh or https to clone
clone_with: https
# HTTPS URL format, Full name will be something like Clivern/Rabbit
https_format: https://github.com/{$full_name}.git
# SSH URL format, Full name will be something like Clivern/Rabbit
ssh_format: [email protected]:{$full_name}.git
# Bitbucket Configs
bitbucket:
# Webhook URI (Full URL will be app.domain + webhook_uri)
Expand Down
21 changes: 16 additions & 5 deletions internal/app/controller/github_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/spf13/viper"
"go.uber.org/zap"
"net/http"
"strings"
)

// GithubListener controller
Expand Down Expand Up @@ -79,16 +80,26 @@ func GithubListener(c *gin.Context, messages chan<- string) {
return
}

href := strings.ReplaceAll(
viper.GetString("integrations.github.https_format"),
"{$full_name}",
createEvent.Repository.FullName,
)

if viper.GetString("integrations.github.clone_with") == "ssh" {
href = strings.ReplaceAll(
viper.GetString("integrations.github.ssh_format"),
"{$full_name}",
createEvent.Repository.FullName,
)
}

releaseRequest := model.ReleaseRequest{
Name: createEvent.Repository.Name,
URL: createEvent.Repository.CloneURL,
URL: href,
Version: createEvent.Ref,
}

if viper.GetString("integrations.github.clone_with") == "ssh" {
releaseRequest.URL = createEvent.Repository.SSHURL
}

validate := pkg.Validator{}

if validate.IsEmpty(releaseRequest.Name) {
Expand Down

0 comments on commit 015f190

Please sign in to comment.