Skip to content

Commit

Permalink
Comment on PR on successful merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Jun 15, 2024
1 parent 2d8b764 commit d9a4ff5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/ff_bot/github/merger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule FFBot.GitHub.Merger do

require Logger

alias FFBot.GitHub.Request

def start_merge(token, repo, pull_request) do
Logger.metadata(
repo: "#{repo["owner"]["login"]}/#{repo["name"]}",
Expand All @@ -32,6 +34,18 @@ defmodule FFBot.GitHub.Merger do
Logger.info("Running clearup")

File.rm_rf(directory)

Logger.info("Send confirmation onto pull request")

Request.comment(
token,
repo["owner"]["login"],
repo["name"],
pull_request["number"],
:success,
"Successfully fast-forwarded commits from `#{pull_request["head"]["label"]}` " <>
"onto `#{repo["default_branch"]}`"
)
end

defp clone_repo(token, repo) do
Expand All @@ -46,10 +60,10 @@ defmodule FFBot.GitHub.Merger do
end

defp merge_pull_req(cloned_repo, pull_request) do
Git.merge(cloned_repo, ["--ff-only", "origin/#{pull_request["head"]["ref"]}"])
{:ok, _} = Git.merge(cloned_repo, ["--ff-only", "origin/#{pull_request["head"]["ref"]}"])
end

defp push_changes(cloned) do
Git.push(cloned)
{:ok, _} = Git.push(cloned)
end
end
1 change: 1 addition & 0 deletions lib/ff_bot/github/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ defmodule FFBot.GitHub.Request do
:info -> ":information_source:"
:warning -> ":warning:"
:error -> ":x:"
:success -> ":white_check_mark:"
end

request(
Expand Down

0 comments on commit d9a4ff5

Please sign in to comment.