branch-names/action.yml

48 lines
1.4 KiB
YAML
Raw Normal View History

2020-12-11 23:22:44 +08:00
name: get-branch-name
2020-12-11 21:15:40 +08:00
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 }}
2020-12-11 21:33:11 +08:00
base_ref:
description: 'The target branch of a pull request'
default: ${{ github.base_ref }}
required: false
head_ref:
description: 'The source branch of a pull request'
default: ${{ github.head_ref }}
required: false
ref:
description: 'The branch that triggered the workflow run.'
default: ${{ github.ref }}
required: false
2020-12-11 21:23:56 +08:00
2020-12-11 21:15:40 +08:00
outputs:
base_ref_branch:
2020-12-11 21:41:21 +08:00
value: ${{ steps.branch.outputs.base_ref_branch }}
2020-12-11 21:15:40 +08:00
description: 'The target branch of a pull request'
head_ref_branch:
2020-12-11 21:41:21 +08:00
value: ${{ steps.branch.outputs.head_ref_branch }}
2020-12-11 21:15:40 +08:00
description: 'The source branch of a pull request'
ref_branch:
2020-12-11 21:41:21 +08:00
value: ${{ steps.branch.outputs.ref_branch }}
2020-12-11 21:15:40 +08:00
description: 'The branch that triggered the workflow run.'
runs:
2020-12-11 21:41:21 +08:00
using: "composite"
steps:
- id: branch
run: |
2020-12-11 21:44:08 +08:00
export BASE_REF=${{ inputs.base_ref }}
export HEAD_REF=${{ inputs.head_ref }}
export REF=${{ inputs.ref }}
echo "::set-output name=base_ref_branch::${BASE_REF/refs\/heads\//}"
echo "::set-output name=head_ref_branch::${HEAD_REF/refs\/heads\//}"
2020-12-11 22:02:49 +08:00
echo "::set-output name=ref_branch::${REF/refs\/pull\//}"
2020-12-11 21:41:21 +08:00
shell: bash
2020-12-11 21:15:40 +08:00
branding:
icon: git-branch
color: white