Skip to content

Commit

Permalink
Add the support for the github.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Nov 18, 2019
1 parent a63613c commit 7f7e2e5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/lorislab/samo/CommonCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ private static CompletableFuture<String> readOutStream(InputStream is) {
}

String gitBranch() {
if (isGitHub()) {
String b = System.getenv("GITHUB_REF");
if (b != null && !b.isEmpty()) {
logVerbose("Github branch: " + b);
return b.replace("refs/heads/", "");
}
}
Return r = cmd("git rev-parse --abbrev-ref HEAD", "Error git branch name");
logVerbose("Git branch: " + r.response);
return r.response;
Expand All @@ -197,4 +204,11 @@ String gitHash(int length) {
logVerbose("Git hash: " + r.response);
return r.response;
}

boolean isGitHub() {
String tmp = System.getenv("GITHUB_ACTIONS");
boolean result = Boolean.parseBoolean(tmp);
logVerbose("? Github: " + result);
return result;
}
}

0 comments on commit 7f7e2e5

Please sign in to comment.