Skip to content

GH Action to extract branch name for commits and PRs

License

Notifications You must be signed in to change notification settings

keptn/gh-action-extract-branch-name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

GH Action to Extract Branch Name for commits and PRs

GitHub release (latest by date)

This repo provides a utility GitHub action for the CI Workflow in the Keptn Project. Nevertheless, this action provides a very basic functionality, as in "Extract the current branch name or Pull Request ID", which is useful for creating artifacts based on the branch name (e.g., docker build . -t my-image:$BRANCH_NAME). In addition, as a convenience, it provides the GIT_SHA of the commit (if executed on a local branch) or the merge commit (if executed on aPull Request).

Note: This requires the full git repo to be cloned, so use fetch-depth: 0

      - name: Check out code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0 # need to checkout "all commits" for certain features to work (e.g., get all changed files)

Inputs

  • GITHUB_REF: Use ${{ github.ref }}

Outputs

  • BRANCH
  • BRANCH_SLUG
  • GIT_SHA

Example usage

      - name: Check out code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0 # need to checkout "all commits" for certain features to work (e.g., get all changed files)
      - name: Extract branch name
        id: extract_branch
        uses: keptn/gh-action-extract-branch-name@main
        with:
          GITHUB_REF: ${{ github.ref }}
      - name: Print outputs
        run: |
          echo "GIT_SHA=${{ steps.extract_branch.outputs.GIT_SHA }}"
          echo "BRANCH_SLUG=${{ steps.extract_branch.outputs.BRANCH_SLUG }}"
          echo "BRANCH=${{ steps.extract_branch.outputs.BRANCH }}"

For a full example, please refer to .github/workflows/main.yml.

About

GH Action to extract branch name for commits and PRs

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages