aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 9f1dd98dcce439f71ba9dea8f7fc479651658027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Redprine
========

Automatically update Redmine issues based on open pull requests.

After opening a pull request, you might need to update the corresponding Redmine
ticket with new status information. This program does that work automatically.

The script should be run through a service manager like `cron` or `launchd`. At
each run, it will fetch all open pull requests for the given project, and update
the corresponding Redmine issue of each new pull request.


## Usage
Several parameters are required to configure the script to enable it to
communicate with both GitHub and Redmine.

Both a [GitHub personal access token][1] and Redmine API key
(`https://redmine.example.com/my/account`) are needed.

Here’s an example script with all required arguments:

	#!/bin/sh

	redprine \
		--github-token 'GITHUB_TOKEN' \
		--github-username 'teddywing' \
		--github-owner-repo 'teddywing/redprine' \
		--redmine-base-url 'https://redmine.eaglejump.co' \
		--redmine-token 'REDMINE_TOKEN' \
		--redmine-json-params 'echo "
			{
				\"issue\": {
					\"status_id\": 4,
					\"done_ratio\": 100,
					\"custom_field_values\": {
						\"1\": \"$0\"
					}
				}
			}
		"'

In `--redmine-json-params`, enter a string containing a Bash command (it will be
executed with `bash -c`). A single argument is passed in `$0` containing the URL
of the issue’s pull request. The format must match Redmine’s JSON parameter for
the [issue update API endpoint][3].

Pull request branches are assumed to start with a four-digit number followed by
a hyphen (e.g. `1234-`), where the number is a Redmine issue ID.


## Install
Requirements:

* `curl`
* [`jq`][2]

Download and copy the [Redprine script][4] into your `PATH`.


## License
Copyright © 2018 Teddy Wing. Licensed under the GNU GPLv3+ (see the included
COPYING file).


[1]: https://github.com/settings/tokens
[2]: https://stedolan.github.io/jq/
[3]: https://www.redmine.org/projects/redmine/wiki/Rest_Issues#Updating-an-issue
[4]: https://raw.githubusercontent.com/teddywing/redprine/master/redprine