Skip to content

Commit d2bff5d

Browse files
committed
Merge branch 'main' into joss
2 parents 1a695fa + 5bbfaf2 commit d2bff5d

File tree

3 files changed

+41
-32
lines changed

3 files changed

+41
-32
lines changed

app/lib/responder_registry.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def self.available_responders
9393
responder_class = Object.const_get(name)
9494
available_responders[responder_class.key] = responder_class
9595
rescue NameError => err
96-
logger.warn("There is a mismatch in a Responder class name/module: #{err.message}")
96+
Logger.new(STDOUT).warn("There is a mismatch in a Responder class name/module: #{err.message}")
9797
end
9898
end
9999

docs/installation.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
Installation
22
============
33

4-
Buffy works listening to events received from GitHub and deciding if/how to reply by passing the received payload to different Responders.
5-
You can fork Buffy and configure the responders you want to use for any specific repository. There is no need for the Buffy fork to be located in the same GitHub user/organization as the repo where it will be used. To have Buffy ready and listening to events you can install it locally or deploy it to a server or service platform.
6-
You'll need the following components:
4+
Buffy functions by monitoring events that are sent from a GitHub repository (e.g., openjournals/joss-reviews). Based on the information in these events, Buffy determines whether and how to respond by passing the event data to different [Responders](https://api.rubyonrails.org/v4.1/classes/ActionController/Responder.html).
75

8-
- A GitHub user to use as the bot with admin permissions on the target repo (usually a member of the organization owning the repo).
6+
You can fork Buffy and configure the responders you want to use for a particular repository, and the fork doesn't necessarily
7+
need to be hosted under the same GitHub user or organization (as the repository where it will be used). For Buffy to be operational, it must be running either through a local installation or deployment to a platform. The following components are necessary for this setup:
8+
9+
- A GitHub user with administrative permissions on the target repository (typically a member of the organization that owns the repository) is required to act as the bot.
910
- An instance of Buffy running
10-
- A webhook configured in the GitHub repo's settings to send events to Buffy
11+
- A webhook configured in the settings of the GitHub repository that will send events to Buffy (e.g., a `reviews` repository).
1112

1213
### Create the bot GitHub user
1314

14-
This will be the user responding to commands in the reviews repo.
15+
This will be the "user" responding to the commands issued from a reviews repository.
1516

1617
**1.** [Sign up at GitHub](https://github.com/join) and create the bot user:
1718

@@ -40,13 +41,13 @@ Some applications and services must be available to use by Buffy:
4041

4142
#### Deployment
4243

43-
We will use here [Heroku](https://www.heroku.com) as an example service to deploy Buffy but you can use any other server or platform.
44+
As an example, we will use [Heroku](https://www.heroku.com) to deploy Buffy. However, any other server or platform can also be used.
4445

45-
**1.** Create a new app in heroku linked to the url of your fork of Buffy. Automatically Heroku will use the `heroku/ruby` buildpack.
46+
**1.** To begin, create a new app in Heroku linked to the URL of your Buffy fork. Heroku will automatically use the `heroku/ruby` buildpack.
4647

47-
- To process background jobs Buffy needs `redis` installed, several add-ons providing it are available: Heroku Redis, RedisGreen, Redis To Go, etc.
48-
- To install the `cloc` dependency there's a buildpack for Heroku available [here](https://github.com/openjournals/heroku-buildpack-cloc).
49-
- Gitinspector can be installed [using npm](https://www.npmjs.com/package/gitinspector). To do so in Heroku, the `heroku/nodejs` buildpack can be added.
48+
- To process background jobs, Buffy needs a `redis` add-on, such as Heroku Redis or RedisGreen etc.
49+
- You can use [this Heroku buildpack](https://github.com/openjournals/heroku-buildpack-cloc) to install the `cloc` dependency.
50+
- You can install Gitinspector using npm by following the instructions [here](https://www.npmjs.com/package/gitinspector). If you plan to deploy to Heroku, you can add the `heroku/nodejs` buildpack to your app.
5051

5152
**2.** In the app settings add the following Config Vars:
5253

@@ -64,23 +65,24 @@ We will use here [Heroku](https://www.heroku.com) as an example service to deplo
6465

6566
There are detailed instructions in the Deploy section of your Heroku app.
6667

67-
**4.** You should now have a public URL with Buffy running. You can test that pointing your browser to `/status`, like for example: `https://your-new-buffy-deploy.herokuapp.com/status` It should return a simple *up and running* message.
68+
**4.** At this point, you should have a public URL pointing to your new Buffy app! To confirm this, you can test it by visiting https://your-new-buffy-deploy.herokuapp.com/status. On success, you should see a basic (*up and running*) message confirming that Buffy is up and running.
6869

6970

7071
### Configure a webhook to send events from GitHub to Buffy
7172

72-
**1.** Go to the settings page of the repository where you want to use buffy. Add a new webhook.
73+
**1.** Navigate to the settings page of the repository that Buffy will be listening to and add a new webhook.
7374

7475
![Add webhook](./images/new_webhook.png "Add webhook")
7576

76-
**2.** Configure the new webhook with:
77+
**2.** Set up the new webhook with the following configuration:
7778

7879
Payload URL: /dispatch path at your public buffy url
7980
Content type: application/json
8081
Secret: The BUFFY_GH_SECRET_TOKEN you configured in the previous step
8182

8283
Select individual events to trigger: **issue comments** and **issues**
84+
8385
![New webhook](./images/webhook.png "New webhook")
8486

8587

86-
If everything went well you should have now your bot responding on the reviews issues. Try `@botname help` for example.
88+
Assuming everything went smoothly, your Buffy instance should now be responding to review issues. You can test this by sending the `@botname help` command from a reviews issue to verify that the bot is functioning as expected.

docs/responders/github_action.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GitHub Action
22
=============
33

4-
This responder triggers workflow run on a GitHub Action using the GitHub API. Optionally if the call is successful (not the result of the workflow run but the call to trigger it) a reply message can be posted as a comment in the issue.
4+
This `buffy` responder dispatches an event to trigger a GitHub Action workflow in a repository, where the workflow is defined by a `.github/workflows/*.yaml` file. If desired, upon a successful event dispatch to trigger the workflow (not the outcome of the workflow run), a reply message can be posted as a comment in the (corresponding review) issue.
55
Allows [labeling](../labeling).
66

77
## Listens to
@@ -17,7 +17,7 @@ For example, if you configure the command to be _compile pdf_, it will respond t
1717

1818
## Requirements
1919

20-
Some parameters are required for the responder to work: the `command` to invoke it, and the `workflow_repo` and `workflow_name` values to identify the action to run. All can be set using the settings YAML file.
20+
Some parameters are required for the responder to work: the `command` to invoke it, and the `workflow_repo` and `workflow_name` values to identify the action to run. All can be set using the respective settings YAML file (e.g., `buffy/config/settings-<environment>.yml`).
2121

2222
## Settings key
2323

@@ -54,22 +54,29 @@ If you want to run multiple responders, use an array of these subparams.
5454
## Examples
5555

5656
**A complete example:**
57+
58+
The following snippet sets up `buffy` to react to a `@editorialbot generate pdf` command issued during a `joss` review:
59+
5760
```yaml
5861
...
5962
github_action:
60-
only: editors
61-
command: compile pdf
62-
description: Generates a PDF based on the paper.md file in the repository
63-
workflow_repo: openjournals/reviews
64-
workflow_name: compile-pdf.yml
65-
inputs:
66-
file: paper.md
67-
data-from-issue:
68-
- branch
69-
- target_repository
70-
mapping:
71-
repository: target_repository
72-
number: issue_id
63+
- draft_paper:
64+
command: generate pdf
65+
workflow_repo: openjournals/joss-papers
66+
workflow_name: draft-paper.yml
67+
workflow_ref: master
68+
description: Generates the pdf paper
69+
data_from_issue:
70+
- branch
71+
- target-repository
72+
- issue_id
73+
mapping:
74+
repository_url: target-repository
7375
...
7476
```
75-
Once the responder is invoked it triggers the _compile-pdf.yml_ workflow on the _openjournals/reviews_ repository passing to it the _file_, _repository_, _branch_ and _number_ inputs.
77+
78+
Once invoked, this `github_action` responder triggers the [_draft-paper_](https://github.com/openjournals/joss-papers/blob/main/.github/workflows/draft-paper.yml) workflow on the [_openjournals/joss-papers_](https://github.com/openjournals/joss-papers) repository (see the [actions tab](https://github.com/openjournals/joss-papers/actions)).
79+
80+
The `data_from_issue` field lists the values of _branch_, _target-repository_, and _issue-id_ (which `buffy` fetches from a review issue body) that serve as input arguments for this action. The optional `mapping` field indicates that the value _target-repository_ is mapped to the _repository_url_ variable.
81+
82+
For additional use cases, please refer to the complete [`settings-production.yml`](https://github.com/openjournals/buffy/blob/joss/config/settings-production.yml) file located under the `joss` branch of `buffy`.

0 commit comments

Comments
 (0)