Skip to content
git-branch

GitHub Action

Manage GitHub branches

v1.0.2 Latest version

Manage GitHub branches

git-branch

Manage GitHub branches

Manage the branches for a given repository

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Manage GitHub branches

uses: julbme/gh-action-manage-branch@v1.0.2

Learn more about this action in julbme/gh-action-manage-branch

Choose a version

Build Lint Commit Messages Quality Gate Status GitHub release (latest SemVer)

GitHub Action to manage branches

The GitHub Action for managing branches of the GitHub repository.

  • Create a new branch
  • Move the branch to another commit
  • Delete a branch

Usage

Example Workflow file

  • Create a branch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Create/Update the branch
        uses: julbme/gh-action-manage-branch@v1
        with:
          name: branch-name
          state: present
          from: ${{ github.ref }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  • Delete a branch
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Delete the branch
        uses: julbme/gh-action-manage-branch@v1
        with:
          name: branch-name
          state: absent
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Inputs

Name Type Default Description
name string Not set Name of the branch. Required
state string present Expected state of the branch. Valid values are present to create the branch or absent to delete the branch
from string github.sha The reference from which to create or update the branch - could be a branch, a tag, a ref or a specific SHA. By default, it takes the commit that triggered the workflow.

Outputs

Name Type Description
ref string Git ref of the branch refs/heads/name, or in case the branch is deleted.
name string Name of the branch, or in case the branch is deleted.
sha sha SHA Commit of the branch, or in case the branch is deleted.

Contributing

This project is totally open source and contributors are welcome.