{"id":13567427,"url":"https://github.com/tj-actions/branch-names","last_synced_at":"2025-05-15T20:03:55.125Z","repository":{"id":37860366,"uuid":"320395719","full_name":"tj-actions/branch-names","owner":"tj-actions","description":":octocat: Github action to retrieve branch or tag names with support for all events.","archived":false,"fork":false,"pushed_at":"2025-04-13T07:59:48.000Z","size":705,"stargazers_count":222,"open_issues_count":0,"forks_count":31,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-11T04:02:08.318Z","etag":null,"topics":["actions","branch","branches","branching","cd","ci","ci-cd","git-branch","github","github-actions","github-actions-ci","github-branch-test","github-branches","workflows"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tj-actions.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["jackton1"],"patreon":null,"open_collective":"tj-actions","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":[]}},"created_at":"2020-12-10T21:35:58.000Z","updated_at":"2025-05-07T10:00:03.000Z","dependencies_parsed_at":"2024-01-21T18:29:31.029Z","dependency_job_id":"463824b1-1067-4f1e-9cae-ee5305c29996","html_url":"https://github.com/tj-actions/branch-names","commit_stats":{"total_commits":564,"total_committers":13,"mean_commits":43.38461538461539,"dds":0.5283687943262412,"last_synced_commit":"e03878996b350fdc5d210d67e84a6ad17cfa992a"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-actions%2Fbranch-names","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-actions%2Fbranch-names/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-actions%2Fbranch-names/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-actions%2Fbranch-names/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj-actions","download_url":"https://codeload.github.com/tj-actions/branch-names/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253708048,"owners_count":21951051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","branch","branches","branching","cd","ci","ci-cd","git-branch","github","github-actions","github-actions-ci","github-branch-test","github-branches","workflows"],"created_at":"2024-08-01T13:02:31.235Z","updated_at":"2025-05-15T20:03:53.221Z","avatar_url":"https://github.com/tj-actions.png","language":null,"funding_links":["https://github.com/sponsors/jackton1","https://opencollective.com/tj-actions","https://www.buymeacoffee.com/jackton1"],"categories":["Misc"],"sub_categories":[],"readme":"## branch-names\n\n[![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge\\\u0026logo=ubuntu\\\u0026logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)\n[![Mac OS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge\\\u0026logo=macos\\\u0026logoColor=F0F0F0)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)\n[![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge\\\u0026logo=windows\\\u0026logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)\n[![Public workflows that use this action.](https://img.shields.io/endpoint?style=for-the-badge\\\u0026url=https%3A%2F%2Fused-by.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Dtj-actions%2Fbranch-names%26badge%3Dtrue%26package_id%3DUGFja2FnZS0yOTQyNTYxMTIz)](https://github.com/search?o=desc\\\u0026q=tj-actions+branch-names+language%3AYAML\\\u0026s=\\\u0026type=Code)\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4df2ae51586b43f1bfd26e1aedc69965)](https://app.codacy.com/gh/tj-actions/branch-names/dashboard?utm_source=gh\\\u0026utm_medium=referral\\\u0026utm_content=\\\u0026utm_campaign=Badge_grade)\n[![CI](https://github.com/tj-actions/branch-names/workflows/CI/badge.svg)](https://github.com/tj-actions/branch-names/actions?query=workflow%3ACI)\n[![Update release version.](https://github.com/tj-actions/branch-names/actions/workflows/sync-release-version.yml/badge.svg)](https://github.com/tj-actions/branch-names/actions/workflows/sync-release-version.yml)\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\nGet a branch or tag name without the `/ref/*` prefix.\n\n## Table of Contents\n\n*   [Features](#features)\n*   [Usage](#usage)\n*   [Inputs](#inputs)\n*   [Outputs](#outputs)\n*   [Events](#events)\n    *   [`push*`](#push)\n    *   [`pull_request*`](#pull_request)\n    *   [`tag*`](#tag)\n    *   [Other supported events](#other-supported-events)\n    *   [Possible usage with actions/checkout](#possible-usage-with-actionscheckout)\n*   [Credits](#credits)\n*   [Report Bugs](#report-bugs)\n*   [Contributors ✨](#contributors-)\n\n## Features\n\n*   Retrieve the current branch name without any prefix. (e.g. `'refs/heads/main'` -\u003e `'main'`)\n*   Retrieve the current tag with an option to strip the prefix (e.g. `v0.0.1` -\u003e `v` -\u003e `0.0.1`)\n*   Detect actions triggered by non default branches\n*   Detect actions triggered by the default branch\n*   Supports all valid [git branch names](https://wincent.com/wiki/Legal_Git_branch_names)\n\n## Usage\n\n```yaml\n...\n\n    steps:\n      - name: Get branch names.\n        id: branch-names\n        uses: tj-actions/branch-names@v8\n        \n      - name: Running on the default branch.\n        if: steps.branch-names.outputs.is_default == 'true'\n        run: |\n          echo \"Running on default: ${{ steps.branch-names.outputs.current_branch }}\" \n        # Outputs: \"Running on default: main\"\n      \n      - name: Running on a pull request branch.\n        if: steps.branch-names.outputs.is_default == 'false'\n        run: |\n          echo \"Running on pr: ${{ steps.branch-names.outputs.current_branch }}\"\n        # Outputs: \"Running on pr: feature/test\"\n      \n      - name: Running on a pull request branch.\n        if: steps.branch-names.outputs.is_default == 'false'\n        run: |\n          echo \"Base branch: ${{ steps.branch-names.outputs.base_ref_branch }}\"\n        # Outputs: \"Base branch: main\"\n        \n      - name: Running on any event.\n        run: |\n          echo \"Default branch: ${{ steps.branch-names.outputs.default_branch }}\"\n        # Outputs: \"Default branch: main\"\n```\n\nIf you feel generous and want to show some extra appreciation:\n\nSupport this project with a :star:\n\n[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]\n\n[buymeacoffee]: https://www.buymeacoffee.com/jackton1\n\n[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\n\n## Inputs\n\n\u003c!-- AUTO-DOC-INPUT:START - Do not remove or modify this section --\u003e\n\n```yaml\n- uses: tj-actions/branch-names@v8\n  id: branch-names\n  with:\n    # Replace forward slashes with hyphens \n    # in branch names e.g. `feature/test` \n    # -\u003e `feature-test` \n    # Type: boolean\n    # Default: \"false\"\n    replace_slashes_with_hyphens: ''\n\n    # The prefix that should be \n    # stripped from the branch e.g. \n    # `release/` -\u003e with a branch \n    # `release/1.0` -\u003e returns `1.0` \n    # Type: string\n    strip_branch_prefix: ''\n\n    # The prefix that should be \n    # stripped from the tag e.g. \n    # `v` -\u003e with a tag \n    # `v0.0.1` -\u003e returns `0.0.1` \n    # Type: string\n    strip_tag_prefix: ''\n\n```\n\n\u003c!-- AUTO-DOC-INPUT:END --\u003e\n\n## Outputs\n\n\u003c!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section --\u003e\n\n|                                     OUTPUT                                      |  TYPE  |                                   DESCRIPTION                                    |\n|---------------------------------------------------------------------------------|--------|----------------------------------------------------------------------------------|\n| \u003ca name=\"output_base_ref_branch\"\u003e\u003c/a\u003e[base\\_ref\\_branch](#output_base_ref_branch) | string |          The target branch of a \u003cbr\u003epull request or tag e.g \u003cbr\u003e`main`           |\n|  \u003ca name=\"output_current_branch\"\u003e\u003c/a\u003e[current\\_branch](#output_current_branch)   | string | The current branch name regardless \u003cbr\u003eof event\\_type e.g `main`, `feature/test`  |\n|  \u003ca name=\"output_default_branch\"\u003e\u003c/a\u003e[default\\_branch](#output_default_branch)   | string |               The default branch name e.g \u003cbr\u003e`main` OR `master`                 |\n| \u003ca name=\"output_head_ref_branch\"\u003e\u003c/a\u003e[head\\_ref\\_branch](#output_head_ref_branch) | string |           The source branch of a \u003cbr\u003epull request e.g `feature/test`             |\n|        \u003ca name=\"output_is_default\"\u003e\u003c/a\u003e[is\\_default](#output_is_default)         | string |  Returns `\"true\"` if the current \u003cbr\u003ebranch is the default else \u003cbr\u003e`\"false\"`.   |\n|              \u003ca name=\"output_is_tag\"\u003e\u003c/a\u003e[is\\_tag](#output_is_tag)               | string |     Returns `\"true\"` if the current \u003cbr\u003ebranch is a tag else \u003cbr\u003e`\"false\"`.      |\n|        \u003ca name=\"output_ref_branch\"\u003e\u003c/a\u003e[ref\\_branch](#output_ref_branch)         | string |      The branch that triggered the \u003cbr\u003eworkflow run. e.g `1/merge`, `main`       |\n|                   \u003ca name=\"output_tag\"\u003e\u003c/a\u003e[tag](#output_tag)                   | string |       The tag that triggered the \u003cbr\u003eworkflow run. e.g `v0.0.1`, `0.0.1`         |\n\n\u003c!-- AUTO-DOC-OUTPUT:END --\u003e\n\n## Events\n\n### `push*`\n\n```yaml\non:\n  push:\n    branches:\n      - main\n\n...\n    steps:\n      - name: Get branch names\n        id: branch-names\n        uses: tj-actions/branch-names@v8\n\n      - name: Current branch names\n        run: |\n          echo \"${{ steps.branch-names.outputs.current_branch }}\"\n        # Outputs: \"main\" the branch that triggered the push event.\n\n      - name: Running on the default branch.\n        if: steps.branch-names.outputs.is_default == 'true'\n        run: |\n          echo \"Running on default: ${{ steps.branch-names.outputs.current_branch }}\"\n        # Outputs: \"Running on default: main\".\n      \n      - name: Running on the default branch (i.e non tag based branch).\n        if: steps.branch-names.outputs.is_tag == 'false' \u0026\u0026 steps.branch-names.outputs.is_default == 'true'\n        run: |\n          echo \"Running on branch: ${{ steps.branch-names.outputs.current_branch }}\"\n        # Outputs: \"Running on branch: main\".\n      \n      - name: Get Ref brach name\n        run: |\n          echo \"${{ steps.branch-names.outputs.ref_branch }}\"\n        #  Outputs: \"main\"\n      \n      - name: Default branch name\n        run: |\n          echo \"${{ steps.branch-names.outputs.default_branch }}\"\n        # Outputs: \"main\" the default branch.\n```\n\n### `pull_request*`\n\n```yaml\non:\n  pull_request:\n    branches:\n      - main\n\n...\n    steps:\n      - name: Get branch names\n        id: branch-names\n        uses: tj-actions/branch-names@v8\n      \n      - name: Current branch names\n        run: |\n          echo \"${{ steps.branch-names.outputs.current_branch }}\"\n        # Outputs: \"feature/test\" current PR branch.\n\n      - name: Running on a non tag based branch and a PR branch.\n        if: steps.branch-names.outputs.is_default == 'false'\n        run: |\n          echo \"Running on branch: ${{ steps.branch-names.outputs.current_branch }}\"\n        # Outputs: \"Running on branch: feature/test\".\n      \n      - name: Running on a pull request (i.e non tag based branch).\n        if: steps.branch-names.outputs.is_tag == 'false' \u0026\u0026 steps.branch-names.outputs.is_default == 'false'\n        run: |\n          echo \"Running on branch: ${{ steps.branch-names.outputs.current_branch }}\"\n        # Outputs: \"Running on branch: feature/test\".\n      \n      - name: Get Ref branch name\n        run: |\n          echo \"${{ steps.branch-names.outputs.ref_branch }}\"\n        #  Outputs: \"1/merge\"\n\n      - name: Get Head Ref branch names (i.e The current pull request branch)\n        run: |\n          echo \"${{ steps.branch-names.outputs.head_ref_branch }}\"\n        # Outputs: \"feature/test\" current PR branch.\n\n      - name: Get Base Ref branch names (i.e The target of a pull request.)\n        run: |\n          echo \"${{ steps.branch-names.outputs.base_ref_branch }}\"\n        # Outputs: \"main\".\n      \n      - name: Default branch names\n        run: |\n          echo \"${{ steps.branch-names.outputs.default_branch }}\"\n        # Outputs: \"main\" the default branch.\n```\n\n### `tag*`\n\n```yaml\non:\n  push:\n    tags:\n      - '*'\n\n...\n    steps:\n      - name: Get branch names\n        id: branch-names\n        uses: tj-actions/branch-names@v8\n        with:\n          strip_tag_prefix: v # Optionally strip the leading `v` from the tag.\n     \n      - name: Running on a tag branch.\n        if: steps.branch-names.outputs.is_tag == 'true'\n        run: |\n          echo \"Running on: ${{ steps.branch-names.outputs.tag }}\"\n        # Outputs: \"Running on: 0.0.1\".\n        \n      - name: Get the current tag\n        if: steps.branch-names.outputs.is_tag == 'true'  # Replaces: startsWith(github.ref, 'refs/tags/')\n        run: |\n          echo \"${{ steps.branch-names.outputs.tag }}\"\n        # Outputs: \"0.0.1\"\n```\n\n### Other supported events\n\nSee [.github/workflows/test.yml](https://github.com/tj-actions/branch-names/blob/main/.github/workflows/test.yml) for more examples.\n\n### Possible usage with [actions/checkout](https://github.com/actions/checkout)\n\n```yaml\non:\n  pull_request:\n    branches:\n      - develop\n    \n jobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Get branch names.\n        id: branch-names\n        uses: tj-actions/branch-names@v8\n      - uses: actions/checkout@v4\n        with:\n          ref: ${{ steps.branch-names.outputs.head_ref_branch }}\n```\n\n*   Free software: [MIT license](LICENSE)\n\n## Credits\n\nThis package was created with [Cookiecutter](https://github.com/cookiecutter/cookiecutter).\n\n## Report Bugs\n\nReport bugs at https://github.com/tj-actions/branch-names/issues.\n\nIf you are reporting a bug, please include:\n\n*   Your operating system name and version.\n*   Any details about your workflow that might be helpful in troubleshooting.\n*   Detailed steps to reproduce the bug.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n\n\u003c!-- markdownlint-disable --\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/loarca\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/22898638?v=4?s=100\" width=\"100px;\" alt=\"Alejandro Loarca\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlejandro Loarca\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/tj-actions/branch-names/commits?author=loarca\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://ianwoodard.me\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/17186604?v=4?s=100\" width=\"100px;\" alt=\"Ian Woodard\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eIan Woodard\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/tj-actions/branch-names/commits?author=IanWoodard\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://home.boidol.dev/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/652404?v=4?s=100\" width=\"100px;\" alt=\"Raphael Boidol\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRaphael Boidol\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/tj-actions/branch-names/commits?author=boidolr\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-actions%2Fbranch-names","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj-actions%2Fbranch-names","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-actions%2Fbranch-names/lists"}