Created
November 20, 2019 20:20
-
-
Save souenzzo/f82c572666d6126cb6873e1f0ba43b76 to your computer and use it in GitHub Desktop.
Run with "clj -A:dev -m user.pr" or "clj -A:pr"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user.pr | |
(:require [cognitect.aws.client.api :as aws] | |
[clj-http.client :as http] | |
[clojure.java.io :as io]) | |
(:import (org.eclipse.jgit.api Git))) | |
(defn slack->request | |
[text] | |
{:method :post | |
:url "https://hooks.slack.com/services/XX/YY/ZZ" | |
:content-type :json | |
:form-params {:text text}}) | |
(defn -main | |
[& _] | |
(let [f (io/file ".") | |
branch (-> f | |
Git/open | |
.getRepository | |
.getBranch) | |
repository-name (-> f .getCanonicalFile .getName) | |
codecommit (aws/client {:api :codecommit}) | |
{:keys [pullRequestId]} (-> (aws/invoke codecommit {:op :CreatePullRequest | |
:request {:title branch | |
:targets [{:repositoryName repository-name | |
:sourceReference branch}]}}) | |
:pullRequest)] | |
(-> (str "Novo PR:" | |
"https://console.aws.amazon.com/codesuite/codecommit/repositories/" | |
repository-name | |
"/pull-requests/" | |
pullRequestId | |
"/changes?region=us-east-1") | |
slack->request | |
http/request | |
:body | |
prn) | |
(System/exit 0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment