Skip to content

Commit 8ae72cb

Browse files
committed
Pipeline updated
1 parent a32f670 commit 8ae72cb

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Publish npm package
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- 'v*' # Триггерим workflow при создании тега, начинающегося с 'v'
77

88
jobs:
99
publish:
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout code
1414
uses: actions/checkout@v4
1515
with:
16-
fetch-depth: 0
16+
fetch-depth: 0 # Получаем всю историю коммитов для работы с тегами
1717

1818
- name: Setup Node.js
1919
uses: actions/setup-node@v4
@@ -39,7 +39,16 @@ jobs:
3939
run: |
4040
echo "Determining branch and version..."
4141
echo "github.ref: ${{ github.ref }}"
42-
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
42+
43+
# Получаем коммит, на который указывает тег
44+
TAG_COMMIT=$(git rev-list -n 1 $TAG_NAME)
45+
echo "TAG_COMMIT: $TAG_COMMIT"
46+
47+
# Определяем, из какой ветки был создан коммит
48+
BRANCH_NAME=$(git branch -a --contains $TAG_COMMIT | grep -E 'remotes/origin/(develop|master)' | sed 's|remotes/origin/||' | head -n 1)
49+
echo "BRANCH_NAME: $BRANCH_NAME"
50+
51+
if [[ "$BRANCH_NAME" == "develop" ]]; then
4352
echo "Tag was created from the develop branch."
4453
TIMESTAMP=$(date -u +"%Y%m%d%H%M%S")
4554
VERSION="${TAG_NAME}-dev${TIMESTAMP}"
@@ -94,7 +103,7 @@ jobs:
94103
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
95104

96105
- name: Commit and push changes to develop
97-
if: github.ref == 'refs/heads/develop' && env.CURRENT_VERSION != env.VERSION
106+
if: env.BRANCH_NAME == 'develop' && env.CURRENT_VERSION != env.VERSION
98107
run: |
99108
echo "Preparing to commit and push changes to develop..."
100109
git config --global user.name "GitHub Actions"

0 commit comments

Comments
 (0)