ci: tag-only pipeline; env test|dev|prod
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
name: cabinet-ci-cd
|
||||
|
||||
# CI/CD: только push git-тега (ручное тегирование на ветке prod|test|dev).
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch:
|
||||
description: 'Ветка для прогона тестов'
|
||||
required: true
|
||||
default: test
|
||||
type: choice
|
||||
options:
|
||||
- prod
|
||||
- test
|
||||
- stage
|
||||
push:
|
||||
tags:
|
||||
- 'cabinet-v*'
|
||||
@@ -23,12 +14,9 @@ env:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/cabinet-v')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }}
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
@@ -43,7 +31,6 @@ jobs:
|
||||
- run: composer audit || true
|
||||
|
||||
parse-tag:
|
||||
if: startsWith(github.ref, 'refs/tags/cabinet-v')
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
full_tag: ${{ steps.meta.outputs.full_tag }}
|
||||
@@ -60,7 +47,6 @@ jobs:
|
||||
|
||||
build-and-push:
|
||||
needs: [test, parse-tag]
|
||||
if: startsWith(github.ref, 'refs/tags/cabinet-v')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -79,7 +65,6 @@ jobs:
|
||||
|
||||
deploy-gitops:
|
||||
needs: [build-and-push, parse-tag]
|
||||
if: startsWith(github.ref, 'refs/tags/cabinet-v')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Bump image tag in sova-deploy
|
||||
@@ -91,7 +76,7 @@ jobs:
|
||||
ENV="${{ needs.parse-tag.outputs.env }}"
|
||||
TAG="${{ needs.parse-tag.outputs.full_tag }}"
|
||||
case "${ENV}" in
|
||||
test|stage|prod) ;;
|
||||
test|dev|prod) ;;
|
||||
*) echo "Unknown env from tag: ${ENV}"; exit 1 ;;
|
||||
esac
|
||||
git clone --branch "${ENV}" --single-branch "${REPO_URL}" sova-deploy 2>/dev/null \
|
||||
|
||||
Reference in New Issue
Block a user