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
-
Method Summary
Modifier and TypeMethodDescription(package private) String
Gets the ref from a branch name.(package private) void
Connects to GitHub API.(package private) org.kohsuke.github.GHRef
createGHRef
(@NonNull String newRef, @NonNull String sourceSHA, @NonNull Optional<org.kohsuke.github.GHRef> existingRef) Creates or updates theGHRef
if any.(package private) void
deleteGHRef
(@NonNull Optional<org.kohsuke.github.GHRef> refToDelete) Deletes theGHRef
if any.void
execute()
(package private) Optional<org.kohsuke.github.GHRef>
getAnyGHRef
(@NonNull String name) Gets theGHRef
branch or tag matching the given name.(package private) Optional<org.kohsuke.github.GHRef>
getBranchGHRef
(@NonNull String name) Gets theGHRef
branch matching the given name.(package private) String
Gets the "from" input.(package private) String
Gets the "name" input.(package private) InputBranchState
Gets the "state" input.(package private) String
Gets the ref from a tag name.
-
Constructor Details
-
ManageBranchGitHubAction
public ManageBranchGitHubAction()
-
-
Method Details
-
execute
public void execute()- Specified by:
execute
in 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 theGHRef
branch matching the given name.- Parameters:
name
- the branch name to look for.- Returns:
- the
GHRef
for the given branch if exists,false
otherwise. - Throws:
IOException
- if an error occurs.
-
getAnyGHRef
Gets theGHRef
branch or tag matching the given name.- Parameters:
name
- the branch or tag name to look for.- Returns:
- the
GHRef
for the given branch or tag if exists,false
otherwise. - 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 theGHRef
if any.- Parameters:
newRef
- the ref to create.sourceSHA
- the SHA from which to create the branch.existingRef
- theGHRef
for the existing branch, orOptional.empty()
if the branch does not exist.- Returns:
- the
GHRef
created. - Throws:
IOException
- if an error occurs.
-
deleteGHRef
void deleteGHRef(@NonNull @NonNull Optional<org.kohsuke.github.GHRef> refToDelete) throws IOException Deletes theGHRef
if any.- Parameters:
refToDelete
- theGHRef
to 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.
-