-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
40 lines (37 loc) · 1.22 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Get current branch name
description: Get current branch name for any trigger (workflow_dispatch, pull_request, etc.)
outputs:
branch-name:
description: Branch name
value: ${{ steps.get-branch-name.outputs.branch-name }}
runs:
using: composite
steps:
- name: Get branch name for pull_request trigger
shell: bash
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]];
then
echo "BRANCH_NAME=${GITHUB_HEAD_REF#refs/heads/}" >> $GITHUB_ENV
fi
exit 0
- name: Get branch name for other triggers
shell: bash
run: |
if [[ "${{ github.event_name }}" != "pull_request" ]] && [[ $GITHUB_REF == refs/heads/* ]];
then
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
fi
exit 0
- name: Get tag name for other triggers
shell: bash
run: |
if [[ "${{ github.event_name }}" != "pull_request" ]] && [[ $GITHUB_REF == refs/tags/* ]];
then
echo "BRANCH_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
exit 0
- name: Set branch name to output
id: get-branch-name
shell: bash
run: echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT