diff --git a/README.md b/README.md index 8b938f7..d9e2716 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,11 @@ The following environment variables must be set: You can also optionally set these variables: -| Variable | Description | Default | -|------------------|-------------------------------------------------------|----------------------| -| `FF_POLICY_FILE` | The file to read for policy on who can perform merges | `.github/ff-bot.yml` | -| `FF_LISTEN_PORT` | The HTTP port for the service to listen on | 4000 | +| Variable | Description | Default | +|--------------------|------------------------------------------------------------------------------------------|----------------------| +| `FF_POLICY_FILE` | The file to read for policy on who can perform merges | `.github/ff-bot.yml` | +| `FF_LISTEN_PORT` | The HTTP port for the service to listen on | 4000 | +| `FF_NO_PROPAGANDA` | Disable all team encouragement messages generated by the bot on merged Pull Requests. | | ## Usage diff --git a/config/runtime.exs b/config/runtime.exs index c957b70..c836ae1 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -5,4 +5,5 @@ config :ff_bot, github_client_id: System.fetch_env!("GITHUB_CLIENT_ID"), github_client_secret: System.fetch_env!("GITHUB_CLIENT_SECRET") |> String.replace("\\n", "\n"), policy_file: System.get_env("FF_POLICY_FILE", ".github/ff-bot.yml"), - service_port: System.get_env("FF_LISTEN_PORT", "4000") |> String.to_integer() + service_port: System.get_env("FF_LISTEN_PORT", "4000") |> String.to_integer(), + disable_propaganda?: System.get_env("FF_NO_PROPAGANDA") diff --git a/lib/ff_bot/github/merger.ex b/lib/ff_bot/github/merger.ex index fa7d3ed..33d146b 100644 --- a/lib/ff_bot/github/merger.ex +++ b/lib/ff_bot/github/merger.ex @@ -44,7 +44,7 @@ defmodule FFBot.GitHub.Merger do pull_request["number"], :success, "Successfully fast-forwarded commits from `#{pull_request["head"]["label"]}` " <> - "onto `#{repo["default_branch"]}`" + "onto `#{repo["default_branch"]}`" <> maybe_propaganda() ) end @@ -66,4 +66,12 @@ defmodule FFBot.GitHub.Merger do defp push_changes(cloned) do {:ok, _} = Git.push(cloned) end + + defp maybe_propaganda do + if Application.get_env(:ff_bot, :disable_propaganda?) == nil and :rand.uniform() < 0.01 do + ". Glory to Arstotzka!" + else + "" + end + end end