Merge branch 'ci/semantic-release-auth-fix' into 'main'

ci(release): fix git auth + fail-fast on missing GITLAB_TOKEN

See merge request 2-6/2-6-4/terravault/ordinis!53
This commit is contained in:
Александр Зимин
2026-05-11 12:22:05 +00:00
+25 -1
View File
@@ -406,12 +406,36 @@ release:
# GL_TOKEN — @semantic-release/gitlab plugin requires this name specifically. # GL_TOKEN — @semantic-release/gitlab plugin requires this name specifically.
GL_TOKEN: $GITLAB_TOKEN GL_TOKEN: $GITLAB_TOKEN
before_script: before_script:
# Fail fast если token не настроен. Job всё равно allow_failure: true —
# pipeline не покраснеет, но в logs понятная причина (вместо cryptic
# "Authentication failed").
- |
if [ -z "$GITLAB_TOKEN" ]; then
echo "═══════════════════════════════════════════════════════════════"
echo "GITLAB_TOKEN is empty — release job will skip."
echo ""
echo "Setup (one-time):"
echo " 1. Settings → Access Tokens → create Project Access Token"
echo " scopes: write_repository + api, role: Maintainer"
echo " 2. Settings → CI/CD → Variables → add GITLAB_TOKEN"
echo " flags: Masked + Protected"
echo ""
echo "См. RELEASE.md в репозитории для подробностей."
echo "═══════════════════════════════════════════════════════════════"
exit 0
fi
- apk add --no-cache git ca-certificates - apk add --no-cache git ca-certificates
# Configure git remote с токеном для push. CI default remote — HTTPS с
# CI_JOB_TOKEN scope, который НЕ может push'ить tags/commits. Переопределяем
# на Project Access Token (GITLAB_TOKEN).
- git remote set-url origin "https://gitlab-ci-token:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
- git config user.email "${GITLAB_USER_EMAIL:-ci@ordinis.local}"
- git config user.name "semantic-release"
- npm install -g --silent pnpm@9.15.4 - npm install -g --silent pnpm@9.15.4
- cd ordinis-admin-ui - cd ordinis-admin-ui
- pnpm install --frozen-lockfile --silent - pnpm install --frozen-lockfile --silent
script: script:
- npx semantic-release - npx semantic-release
# Не блокирует следующие pipelines если release fail'нул (e.g. нет # Не блокирует следующие pipelines если release fail'нул (e.g. нет
# релизных commits). Manual investigation если нужно. # релизных commits, нет GITLAB_TOKEN, transient network error).
allow_failure: true allow_failure: true