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 Details

    • ManageBranchGitHubAction

      public ManageBranchGitHubAction()
  • Method Details

    • execute

      public void execute()
      Specified by:
      execute in interface me.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

      void connectApi() throws IOException
      Connects to GitHub API.
      Throws:
      IOException - if an error occurs.
    • getBranchGHRef

      Optional<org.kohsuke.github.GHRef> getBranchGHRef(@NonNull @NonNull String name) throws IOException
      Gets the GHRef 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

      Optional<org.kohsuke.github.GHRef> getAnyGHRef(@NonNull @NonNull String name) throws IOException
      Gets the GHRef 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 the GHRef if any.
      Parameters:
      newRef - the ref to create.
      sourceSHA - the SHA from which to create the branch.
      existingRef - the GHRef for the existing branch, or Optional.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 the GHRef if any.
      Parameters:
      refToDelete - the GHRef to delete, or Optional.empty().
      Throws:
      IOException - if an error occurs.
    • branchRef

      String branchRef(@NonNull @NonNull String branchName)
      Gets the ref from a branch name.
      Parameters:
      branchName - the branch name.
      Returns:
      the ref for the given branch name.
    • tagRef

      String tagRef(@NonNull @NonNull String name)
      Gets the ref from a tag name.
      Parameters:
      name - the tag name.
      Returns:
      the ref for the given tag name.