• Stars
    star
    172
  • Rank 221,201 (Top 5 %)
  • Language
    Go
  • License
    Other
  • Created almost 7 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Package scm provides a unified interface to multiple source code management systems.

go-scm

Go Doc

Package scm provides a unified interface to multiple source code management systems including GitHub, GitHub Enterprise, Bitbucket, Bitbucket Server, Gitee, Gitea and Gogs.

Getting Started

Create a GitHub client:

package main

import (
  "github.com/drone/go-scm/scm"
  "github.com/drone/go-scm/scm/driver/github"
)

func main() {
client := github.NewDefault()
}

Create a GitHub Enterprise client:

import (
  "github.com/drone/go-scm/scm"
  "github.com/drone/go-scm/scm/driver/github"
)

func main() {
    client, err := github.New("https://github.company.com/api/v3")
}

Create a Bitbucket client:

import (
  "github.com/drone/go-scm/scm"
  "github.com/drone/go-scm/scm/driver/bitbucket"
)

func main() {
    client, err := bitbucket.New()
}

Create a Bitbucket Server (Stash) client:

import (
  "github.com/drone/go-scm/scm"
  "github.com/drone/go-scm/scm/driver/stash"
)

func main() {
    client, err := stash.New("https://stash.company.com")
}

Create a Gitea client:

import (
  "github.com/drone/go-scm/scm"
  "github.com/drone/go-scm/scm/driver/gitea"
)

func main() {
  client, err := gitea.New("https://gitea.company.com")
}

Create a Gitee client:

import (
  "github.com/drone/go-scm/scm"
  "github.com/drone/go-scm/scm/driver/gitee"
)

func main() {
  client, err := gitee.New("https://gitee.com/api/v5")
}

Authentication

The scm client does not directly handle authentication. Instead, when creating a new client, provide an http.Client that can handle authentication for you. For convenience, this library includes oauth1 and oauth2 implementations that can be used to authenticate requests.

package main

import (
  "github.com/drone/go-scm/scm"
  "github.com/drone/go-scm/scm/driver/github"
  "github.com/drone/go-scm/scm/transport"
  "github.com/drone/go-scm/scm/transport/oauth2"
)

func main() {
  client := github.NewDefault()

  // provide a custom http.Client with a transport
  // that injects the oauth2 token.
  client.Client = &http.Client{
    Transport: &oauth2.Transport{
      Source: oauth2.StaticTokenSource(
        &scm.Token{
          Token: "ecf4c1f9869f59758e679ab54b4",
        },
      ),
    },
  }

  // provide a custom http.Client with a transport
  // that injects the private GitLab token through
  // the PRIVATE_TOKEN header variable.
  client.Client = &http.Client{
    Transport: &transport.PrivateToken{
      Token: "ecf4c1f9869f59758e679ab54b4",
    },
  }
}

Usage

The scm client exposes dozens of endpoints for working with repositories, issues, comments, files and more. Please see the godocs to learn more.

Example code to get an issue:

issue, _, err := client.Issues.Find(ctx, "octocat/Hello-World", 1)

Example code to get a list of issues:

opts := scm.IssueListOptions{
  Page:   1,
  Size:   30,
  Open:   true,
  Closed: false,
}

issues, _, err := client.Issues.List(ctx, "octocat/Hello-World", opts)

Example code to create an issue comment:

in := &scm.CommentInput{
  Body: "Found a bug",
}

comment, _, err := client.Issues.CreateComment(ctx, "octocat/Hello-World", 1, in)

Useful links

Here are some useful links to providers API documentation:

Release procedure

Run the changelog generator.

docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone -p go-scm -t <secret github token>

You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens.

Next we tag the PR's with the fixes or enhancements labels. If the PR does not fufil the requirements, do not add a label.

Run the changelog generator again with the future version according to semver.

docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone -p go-scm -t <secret token> --future-release v1.15.2

Create your pull request for the release. Get it merged then tag the release.

More Repositories

1

drone-ui

Front-end for the Drone continuous integration server
JavaScript
470
star
2

routes

[DEPRECATED] routing API for Go web applications
Go
340
star
3

envsubst

Go package emulates bash environment variable substitution
Go
270
star
4

drone-go

Go client for the Drone API
Go
268
star
5

drone-wall

Dashboard for the Drone CI server
JavaScript
260
star
6

go.stripe

a simple Credit Card processing library for Go using the Stripe API
Go
260
star
7

autoscaler

Automatically adds or removes instances based on build volume
Go
193
star
8

sqlgen

Go tool for generating sql scanners, sql statements and other helper functions
Go
183
star
9

charts

Helm charts for the Drone platform on Kubernetes
Go
168
star
10

jkl

[DEPRECATED] a static site generator written in Go based on Jekyll
Go
132
star
11

docs

Documentation for the Drone Continuous Integration project
SCSS
114
star
12

awesome-drone

A curated list of awesome Drone resources.
104
star
13

drone-plugin-index

Public index of Drone plugins
JavaScript
74
star
14

drone-gc

Garbage collection of unused docker resources
Go
73
star
15

drone-vault

Drone plugin for integrating with the Vault secrets manager
Go
64
star
16

drone-node

Node client for the Drone API
JavaScript
62
star
17

drone-runtime

[DEPRECATED] migrated to https://github.com/drone-runners
Go
62
star
18

drone-kaniko

Drone plugin for building and publishing Docker images
Go
56
star
19

drone-git

Drone plugin for cloning Git repositories
Go
53
star
20

drone-kubernetes-runtime

Goto drone/drone-runtime
Go
47
star
21

mq

a lightweight STOMP message broker
Go
42
star
22

drone-yaml

Go package for parsing and compiling the drone yaml file
Go
41
star
23

runner-go

Go helper package to extend Drone with customer runners.
Go
38
star
24

ca-certs

Docker image from scratch with root certificates
37
star
25

drone-plugin-starter

Starter project for creating Drone plugins
Go
34
star
26

drone-migrate

Migration utility from Drone 0.8.x to 1.0.x
Go
33
star
27

go-bitbucket

[DEPRECATED] Go bindings for the Bitbucket API
Go
28
star
28

go-login

Package login provides login handlers for multiple Source Control Management systems.
Go
28
star
29

drone-js

Javascript client for the Drone API
JavaScript
23
star
30

tutorials

Hugo project for the Drone tutorials website
CSS
20
star
31

homebrew-drone

Homebrew repository to install the Drone command line utility
Ruby
19
star
32

drone-convert-starlark

DEPRECATED: native Starlark support was added to Drone core. This extension is no longer required and has been deprecated.
Go
16
star
33

boilr-config

boilr template for creating Drone configuration extensions
Go
13
star
34

proposal

Drone Project Design Documents
13
star
35

drone-template-lib

library for generating templates in notification plugins
Go
13
star
36

hello-world

simple repository with CI enabled
Dockerfile
12
star
37

drone-registry-plugin

Registry extension for backward compatibility with 0.8 global registry credentials.
Go
12
star
38

docs.drone.io

[DEPRECATED] Documentation for Drone.io continuous integration service
CSS
12
star
39

drone-jsonnet-config

Drone extensions to support Jsonnet configuration files
Go
12
star
40

boilr-plugin

boilr template for creating Drone plugins
Go
11
star
41

drone-plugin-go

[DEPRECATED] use drone-go instead
Go
11
star
42

go-convert

Package convert provides tools for converting pipeline configuration files to the Drone format.
Go
11
star
43

drone-docker

Drone plugin for building and publishing Docker images
Go
9
star
44

boilr-metrics

boilr template for creating custom Drone metrics providers
Go
8
star
45

drone-cache-lib

library for building cache plugins
Go
8
star
46

brand

Logos and branding
8
star
47

drone-amazon-secrets

Drone plugin for integrating with the AWS Secrets Manager
Go
7
star
48

signal

Go package implements Context for os/signal
Go
7
star
49

drone-jira

Drone plugin for sending build and deployment status updates to Jira
Go
7
star
50

autoscaler-docs

Documentation for the Drone Autoscaler
6
star
51

drone-hugo-theme

Hugo theme for Drone documentation
CSS
6
star
52

go-license

Package license provides software license management utilities
Go
6
star
53

boilr-convert

boilr template for creating Drone conversion extensions
Go
5
star
54

ui-template

Harness micro-frontend template
TypeScript
5
star
55

boilr-webhook

boilr template for creating Drone webhook extensions
Go
4
star
56

spec

JavaScript
4
star
57

ui-core

Experimental React component library for Drone.
TypeScript
4
star
58

boilr-runner

boilr template for creating custom pipeline runners
Go
4
star
59

funcmap

Template functions for Go templates
Go
3
star
60

plugin

Tool to execute plugins
Go
3
star
61

drone-gitleaks

Drone Plugin for detecting credentials or other sensitive data in your repository
Go
3
star
62

blog

static website for blog.drone.io
HTML
3
star
63

boilr-admission

boilr template for creating Drone admission extensions
Go
3
star
64

drone-admit-members

Drone extension to restrict access based on organization membership
Go
3
star
65

go-task

Go
3
star
66

ff-test-cases

Test cases for FF SDKs evaluator tests
Go
2
star
67

go-generate

Package generate provides tools for generating pipeline configuration files in the Drone format.
Go
2
star
68

boilr-secret

boilr template for creating Drone secret extensions
Go
2
star
69

boilr-environ

boilr template for creating Drone environment variable extensions
Go
2
star
70

ff-nodejs-server-sample

ff-nodejs-server-sample
JavaScript
2
star
71

ff-ios-client-sample

Swift
2
star
72

drone-yaml-v1

moved to https://github.com/drone/drone-yaml
Go
1
star
73

drone.js

[MOVED] Javascript client for the Drone API
JavaScript
1
star
74

drone-secret-plugin

Secrets extension for backward compatibility with 0.8 global secrets files.
Go
1
star
75

ff-java-server-sample

Sample application using Java Server SDK
Java
1
star
76

ff-dotnetcore-server-sample

C#
1
star
77

ff-javascript-client-sample

JavaScript
1
star
78

hubot-drone

1
star
79

expr

Go package evaluates SQL expressions
Go
1
star
80

ff-dotnet-server-sample

C#
1
star
81

ff-golang-server-sample

Go
1
star
82

ff-flutter-client-sample

Dart
1
star