Skip to content

hughack/branch-tag-parser

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tag and Branch Processor Action

Overview

This GitHub Action processes git references (tags and branches) for CI/CD workflows. It handles both full and shortened references, converting them into a format suitable for various deployment and versioning scenarios.

Features

  • Processes tag and branch references.
  • Only supports full references (refs/heads/..., refs/tags/...), will add more support in the future.
  • Extracts and processes parts of tags and branches for versatile use.

Inputs

  • ref: The git reference (tag or branch) to process.

Outputs

  • reference_type: Indicates whether the input is a tag or a branch.
  • original_ref: The original reference string.
  • tag_prefix: Unprocessed prefix part of the tag (if applicable).
  • tag_prefix_processed: Processed tag prefix with slashes replaced by dashes.
  • tag_suffix: Suffix part of the tag (if applicable).
  • tag_suffix_processed: Processed tag suffix with slashes replaced by dashes.
  • branch_name: Unprocessed branch name (if applicable).
  • branch_name_processed: Processed branch name with slashes replaced by dashes.

Usage

Include this action in your GitHub Actions workflow to process git references:

jobs:
  process-git-ref:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Process Git Reference
      id: ref_processor
      uses: hughack/branch-tag-parser@<version>
      with:
        ref: ${{ github.ref }}

    - name: Use Outputs
      run: |
        echo "Reference Type: ${{ steps.ref_processor.outputs.reference_type }}"
        echo "Original Reference: ${{ steps.ref_processor.outputs.original_ref }}"
        # ... additional echos for other outputs ...

Example

Here's an example of how to use this action in a workflow:

name: Example Workflow

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: Process Git Reference
      uses: ./.github/actions/tag-and-branch-processor
      with:
        ref: ${{ github.ref }}

    - name: Display Processed Reference
      run: echo "Processed Reference: ${{ steps.ref_processor.outputs.branch_name_processed }}"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published