Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ jobs:
runs-on: ubuntu-latest
name: Test action
steps:
- uses: actions/checkout@v7
- name: Use action
id: get-branch
uses: codio/get-branch-name-github-action@master
- name: Echo outpus
uses: ./
- name: Echo outputs
run: echo "name=${{ steps.get-branch.outputs.branch }} - tag=${{ steps.get-branch.outputs.tag }}"
9 changes: 0 additions & 9 deletions Dockerfile

This file was deleted.

18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Get-Branch-Name Github Action

This action outputs the current branch name and corresponding tag.
This action outputs the current branch name and corresponding tag. Composite action: one `bash` step, no container build per run and no Node runtime to deprecate.

## Outputs

### `branch`
The current branch name.

The current branch name — `GITHUB_REF` with the `refs/heads/` prefix removed. Refs that are not branches (tags, pull requests) come through unchanged, e.g. `refs/tags/v1`.

### `tag`
The corresponding tag name. If `master` -> `latest`, `branch-name` for the others.

`master` on the master branch, `latest` when the ref is a tag, empty otherwise.

## Example usage

```yaml
- name: Get Current Branch
id: get-branch
uses: codio/get-branch-name-github-action@v2

- run: echo "${{ steps.get-branch.outputs.branch }} / ${{ steps.get-branch.outputs.tag }}"
```
uses: ypicard/get-branch-name-github-action@v1
```
23 changes: 20 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@
name: 'Get Branch Name and Tag'
description: 'Get current branch name and corresponding branch tag if needed.'
branding:
icon: 'activity'
icon: 'activity'
color: 'white'
outputs:
branch:
description: 'Current branch name'
value: ${{ steps.get-branch.outputs.branch }}
tag:
description: 'Corresponding branch tag'
value: ${{ steps.get-branch.outputs.tag }}
runs:
using: 'docker'
image: 'Dockerfile'
using: composite
steps:
- id: get-branch
shell: bash
run: |
set -euo pipefail
branch="${GITHUB_REF#refs/heads/}"
tag=''
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
tag='latest'
elif [[ "${branch}" == 'master' ]]; then
tag='master'
fi
{
echo "branch=${branch}"
echo "tag=${tag}"
} >> "${GITHUB_OUTPUT}"
15 changes: 0 additions & 15 deletions entrypoint.sh

This file was deleted.