commit c5308c6d98ef23ee7f672f6fc3aa92acd7ad611d Author: Tonye Jack Date: Fri Dec 11 08:15:40 2020 -0500 Initial commit. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..b0f25ab --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,10 @@ +* branch-name: + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +Add some details about your workflow ? diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..117d019 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + name: Test branch-name + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: shellcheck + uses: reviewdog/action-shellcheck@v1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a53c681 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +.envrc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4cea456 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.12 + +LABEL maintainer="Tonye Jack " + +RUN apk add bash + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 0000000..c896530 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,7 @@ +History +------- + +v1 (2020-12-11) +------------------ + +* Initial Release. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fcdbce7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2020, Tonye Jack + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..1e3ab96 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +branch-name +----------- + +Retrieve giithub branch information without any prefix + +```yaml +... + steps: + - uses: actions/checkout@v2 + - name: Get branch name + uses: tj-actions/branch-name@v1 +``` + + +## Inputs + +| Input | type | required | default | +|:-------------:|:-----------:|:-------------:|:---------------------:| +| token | `string` | `false` | `${{ github.token }}` | + + + +* Free software: [MIT license](LICENSE) + +Features +-------- + +* TODO + + +Credits +------- + +This package was created with [Cookiecutter](https://github.com/cookiecutter/cookiecutter). + + + +Report Bugs +----------- + +Report bugs at https://github.com/tj-actions/branch-name/issues. + +If you are reporting a bug, please include: + +* Your operating system name and version. +* Any details about your workflow that might be helpful in troubleshooting. +* Detailed steps to reproduce the bug. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..61c08a4 --- /dev/null +++ b/action.yml @@ -0,0 +1,27 @@ +name: Get branch name +description: Retrieve giithub branch information without `/ref/heads` prefix +author: tj-actions +inputs: + token: + description: 'GITHUB_TOKEN or a Repo scoped PAT' + required: true + default: ${{ github.token }} + +outputs: + base_ref_branch: + description: 'The target branch of a pull request' + head_ref_branch: + description: 'The source branch of a pull request' + ref_branch: + description: 'The branch that triggered the workflow run.' + +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ github.base_ref }} + - ${{ github.head_ref }} + - ${{ github.ref }} +branding: + icon: git-branch + color: white diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..0ff7b61 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +echo "::set-output name=base_ref_branch::${0/refs\/heads\//}" +echo "::set-output name=head_ref_branch::${1/refs\/heads\//}" +echo "::set-output name=ref_branch::${2/refs\/heads\//}"