Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5702c7178e | |||
| ecdfb17805 |
@@ -1,17 +1,9 @@
|
|||||||
name: backend-ci-cd
|
name: backend-ci-cd
|
||||||
|
|
||||||
|
# CI/CD: только push git-тега (ручное тегирование на ветке prod|test|stage).
|
||||||
|
# Push в ветки и feature-ветки pipeline не запускают.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
branch:
|
|
||||||
description: 'Ветка для прогона тестов'
|
|
||||||
required: true
|
|
||||||
default: test
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- prod
|
|
||||||
- test
|
|
||||||
- stage
|
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'backend-v*'
|
- 'backend-v*'
|
||||||
@@ -23,12 +15,9 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/backend-v')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }}
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
@@ -45,7 +34,6 @@ jobs:
|
|||||||
- run: composer audit || true
|
- run: composer audit || true
|
||||||
|
|
||||||
parse-tag:
|
parse-tag:
|
||||||
if: startsWith(github.ref, 'refs/tags/backend-v')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
full_tag: ${{ steps.meta.outputs.full_tag }}
|
full_tag: ${{ steps.meta.outputs.full_tag }}
|
||||||
@@ -62,7 +50,6 @@ jobs:
|
|||||||
|
|
||||||
build-and-push:
|
build-and-push:
|
||||||
needs: [test, parse-tag]
|
needs: [test, parse-tag]
|
||||||
if: startsWith(github.ref, 'refs/tags/backend-v')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -81,7 +68,6 @@ jobs:
|
|||||||
|
|
||||||
deploy-gitops:
|
deploy-gitops:
|
||||||
needs: [build-and-push, parse-tag]
|
needs: [build-and-push, parse-tag]
|
||||||
if: startsWith(github.ref, 'refs/tags/backend-v')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Bump image tag in sova-deploy
|
- name: Bump image tag in sova-deploy
|
||||||
@@ -94,7 +80,7 @@ jobs:
|
|||||||
TAG="${{ needs.parse-tag.outputs.full_tag }}"
|
TAG="${{ needs.parse-tag.outputs.full_tag }}"
|
||||||
case "${ENV}" in
|
case "${ENV}" in
|
||||||
test|stage|prod) ;;
|
test|stage|prod) ;;
|
||||||
*) echo "Unknown env from tag: ${ENV}"; exit 1 ;;
|
*) echo "Unknown env from tag: ${ENV} (expected test|stage|prod)"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
git clone --branch "${ENV}" --single-branch "${REPO_URL}" sova-deploy 2>/dev/null \
|
git clone --branch "${ENV}" --single-branch "${REPO_URL}" sova-deploy 2>/dev/null \
|
||||||
|| { git clone "${REPO_URL}" sova-deploy && cd sova-deploy && git checkout -B "${ENV}"; }
|
|| { git clone "${REPO_URL}" sova-deploy && cd sova-deploy && git checkout -B "${ENV}"; }
|
||||||
|
|||||||
Reference in New Issue
Block a user