From dd2a37ee13cb68334476bb3f935ca88ab51da07d Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Sat, 23 Sep 2017 18:59:18 +0200 Subject: [PATCH 1/3] Reparing microbadger --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index a889950..4fd4711 100644 --- a/.drone.yml +++ b/.drone.yml @@ -100,10 +100,10 @@ pipeline: # event: push microbadger: - image: jonasfranz/crowdin:1 + image: plugins/webhook:1 pull: true secrets: [ webhook_url ] when: branch: master event: push - status: [ success ] \ No newline at end of file + status: [ success ] From ec3cf3004c06a211fcc45679d2f3944c5b440cb5 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Sat, 23 Sep 2017 19:01:59 +0200 Subject: [PATCH 2/3] Update Dockerfile.windows --- Dockerfile.windows | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 4683472..e6fb37a 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,4 +1,4 @@ -FROM plugins/base:multiarch +FROM plugins/base:amd64 MAINTAINER Jonas Franz LABEL org.label-schema.version=latest @@ -8,4 +8,4 @@ LABEL org.label-schema.vendor="Jonas Franz" LABEL org.label-schema.schema-version="1.0" ADD release/windows/amd64/drone-crowdin /bin/ -ENTRYPOINT ["/bin/drone-crowdin"] \ No newline at end of file +ENTRYPOINT ["/bin/drone-crowdin"] From 39fb5cfbe02363aa38ea7a4b4ca7ba03580ead91 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Sat, 23 Sep 2017 19:39:56 +0200 Subject: [PATCH 3/3] Adding crowdin branch support (#1) * Adding crowdin branch support Signed-off-by: Jonas Franz * Adding documentation for ignore_branche Signed-off-by: Jonas Franz --- DOCS.md | 1 + main.go | 14 ++++++++++++++ plugin.go | 11 ++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/DOCS.md b/DOCS.md index 9ac33dd..bdbd5f2 100644 --- a/DOCS.md +++ b/DOCS.md @@ -7,6 +7,7 @@ You must provide in your configuration: * `files` - Map of files to upload to Crowdin * key: the Crowdin file name * value: the real path the to file +* `ignore_branch` It will send the Drone branch to Crowdin if it is `false`. (Default: `false`) Information about API keys: https://support.crowdin.com/api/api-integration-setup/ ## Example diff --git a/main.go b/main.go index 5fe9d3c..9162c98 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,17 @@ func main() { EnvVar: "PLUGIN_FILES", Value: &StringMapFlag{}, }, + cli.StringFlag{ + Name: "commit.branch", + Value: "master", + Usage: "git commit branch", + EnvVar: "DRONE_COMMIT_BRANCH", + }, + cli.BoolFlag{ + Name: "ignore-branch", + Usage: "if true it will not pass the branch to crowdin", + EnvVar: "PLUGIN_IGNORE_BRANCH", + }, } if err := app.Run(os.Args); err != nil { log.Fatal(err) @@ -47,5 +58,8 @@ func run(c *cli.Context) error { Key: c.String("project-key"), }, } + if !c.Bool("ignore-branch") { + plugin.Branch = c.String("commit.branch") + } return plugin.Exec() } diff --git a/plugin.go b/plugin.go index 53ee0da..7714b0c 100644 --- a/plugin.go +++ b/plugin.go @@ -26,6 +26,7 @@ type ( Plugin struct { Config Config Files Files + Branch string } ) @@ -57,9 +58,13 @@ func (p Plugin) Exec() error { if _, err = io.Copy(part, file); err != nil { return err } - if err = writer.Close(); err != nil { - return err - } + } + // Adding branch if it is not ignored + if p.Branch != "" { + writer.WriteField("branch", p.Branch) + } + if err := writer.Close(); err != nil { + return err } var req *http.Request var err error