Skip to content

Commit e7eb320

Browse files
committed
chore(ci): Publish - rework branch detector
1 parent 5827244 commit e7eb320

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

.github/workflows/publish.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,16 +791,19 @@ jobs:
791791
steps:
792792
- name: Checkout
793793
uses: actions/checkout@v4
794+
with:
795+
fetch-depth: 0
794796
- name: Detect branch name
795797
id: detect_branch
796-
env:
797-
EVENT_BASE_REF: ${{ github.event.base_ref || 'tag_on_unknown_branch_commit_not_pushed' }}
798798
run: |
799-
BRANCH=${EVENT_BASE_REF#refs/heads/}
799+
GIT_BRANCHES=$(git branch -r --contains ${{ github.ref_name }})
800+
echo "Git contains: $GIT_BRANCHES"
801+
802+
BRANCH="$(echo ${GIT_BRANCHES//origin\//} | tr -d '\n')"
800803
801-
if [ "$BRANCH" == "tag_on_unknown_branch_commit_not_pushed" ]; then
802-
echo "Error: Could not detect branch name. Most likely this is that commit for tag is not pushed yet."
803-
exit 1
804+
if [[ -z $BRANCH ]]; then
805+
echo "Error: Could not detect branch name. Most likely this is that commit for tag is not pushed yet."
806+
exit 1
804807
fi
805808
806809
echo "Detected branch: $BRANCH"

0 commit comments

Comments
 (0)