Class ManageBranchGitHubAction
java.lang.Object
me.julb.applications.github.actions.ManageBranchGitHubAction
- All Implemented Interfaces:
me.julb.sdk.github.actions.spi.GitHubActionProvider
public class ManageBranchGitHubAction
extends Object
implements me.julb.sdk.github.actions.spi.GitHubActionProvider
The action to manage branches.
- Author:
- Julb.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) StringGets the ref from a branch name.(package private) voidConnects to GitHub API.(package private) org.kohsuke.github.GHRefcreateGHRef(@NonNull String newRef, @NonNull String sourceSHA, @NonNull Optional<org.kohsuke.github.GHRef> existingRef) Creates or updates theGHRefif any.(package private) voiddeleteGHRef(@NonNull Optional<org.kohsuke.github.GHRef> refToDelete) Deletes theGHRefif any.voidexecute()(package private) Optional<org.kohsuke.github.GHRef>getAnyGHRef(@NonNull String name) Gets theGHRefbranch or tag matching the given name.(package private) Optional<org.kohsuke.github.GHRef>getBranchGHRef(@NonNull String name) Gets theGHRefbranch matching the given name.(package private) StringGets the "from" input.(package private) StringGets the "name" input.(package private) InputBranchStateGets the "state" input.(package private) StringGets the ref from a tag name.
-
Constructor Details
-
ManageBranchGitHubAction
public ManageBranchGitHubAction()
-
-
Method Details
-
execute
public void execute()- Specified by:
executein interfaceme.julb.sdk.github.actions.spi.GitHubActionProvider
-
getInputName
String getInputName()Gets the "name" input.- Returns:
- the "name" input.
-
getInputState
InputBranchState getInputState()Gets the "state" input.- Returns:
- the "state" input.
-
getInputFrom
String getInputFrom()Gets the "from" input.- Returns:
- the "from" input.
-
connectApi
Connects to GitHub API.- Throws:
IOException- if an error occurs.
-
getBranchGHRef
Gets theGHRefbranch matching the given name.- Parameters:
name- the branch name to look for.- Returns:
- the
GHReffor the given branch if exists,falseotherwise. - Throws:
IOException- if an error occurs.
-
getAnyGHRef
Gets theGHRefbranch or tag matching the given name.- Parameters:
name- the branch or tag name to look for.- Returns:
- the
GHReffor the given branch or tag if exists,falseotherwise. - Throws:
IOException- if an error occurs.
-
createGHRef
org.kohsuke.github.GHRef createGHRef(@NonNull @NonNull String newRef, @NonNull @NonNull String sourceSHA, @NonNull @NonNull Optional<org.kohsuke.github.GHRef> existingRef) throws IOException Creates or updates theGHRefif any.- Parameters:
newRef- the ref to create.sourceSHA- the SHA from which to create the branch.existingRef- theGHReffor the existing branch, orOptional.empty()if the branch does not exist.- Returns:
- the
GHRefcreated. - Throws:
IOException- if an error occurs.
-
deleteGHRef
void deleteGHRef(@NonNull @NonNull Optional<org.kohsuke.github.GHRef> refToDelete) throws IOException Deletes theGHRefif any.- Parameters:
refToDelete- theGHRefto delete, orOptional.empty().- Throws:
IOException- if an error occurs.
-
branchRef
Gets the ref from a branch name.- Parameters:
branchName- the branch name.- Returns:
- the ref for the given branch name.
-
tagRef
Gets the ref from a tag name.- Parameters:
name- the tag name.- Returns:
- the ref for the given tag name.
-