-
-
Save Firemoon777/2695dc9518f09ee0e84952eaa007274e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Воркфлоу описывает базовые условия, когда пайплайн должен создаваться | |
workflow: | |
rules: | |
# Пайплайн в контексте MR | |
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' | |
# Если контекст коммита, но есть открытый MR, то НЕ запускаемся | |
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS' | |
when: never | |
# Одинокий коммит ИЛИ тэг | |
- if: '$CI_COMMIT_BRANCH || $CI_COMMIT_TAG' | |
variables: | |
PARENT_PIPELINE_SOURCE: "$CI_PIPELINE_SOURCE" | |
PARENT_LABELS: "$CI_MERGE_REQUEST_LABELS" | |
.trigger: | |
trigger: | |
include: | |
- local: packages/$PROJECT/.gitlab-ci.yml | |
strategy: depend | |
# Передаем переменные в дочерние пайплайны | |
forward: | |
# Переменные CI, например, секреты | |
pipeline_variables: true | |
# Переменные из блока variables | |
yaml_variables: true | |
amicia: | |
extends: .trigger | |
variables: | |
PROJECT: "amicia" | |
hugo: | |
extends: .trigger | |
variables: | |
PROJECT: "hugo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build-ci | |
- test | |
workflow: | |
rules: | |
- if: $CI_PIPELINE_SOURCE == "parent_pipeline" | |
.test-template: | |
stage: test | |
image: "$CI_IMAGE_NAME" | |
variables: | |
CI_IMAGE_NAME: "$CI_REGISTRY_IMAGE/ci-base-image-$PROJECT:$CI_COMMIT_SHA" | |
rules: | |
- if: '$CI_MERGE_REQUEST_LABELS !~ /skip-tests/' | |
script: | |
- echo $PARENT_LABELS | |
- sleep 30 | |
.build-template: | |
stage: build-ci | |
image: docker:latest | |
variables: | |
CI_IMAGE_NAME: "$CI_REGISTRY_IMAGE/ci-base-image-$PROJECT:$CI_COMMIT_SHA" | |
before_script: | |
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} | |
script: | |
- docker build --tag "$CI_IMAGE_NAME" -f ./Dockerfile . | |
- docker push "$CI_IMAGE_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include: | |
- '/gitlab-ci/template.yml' | |
variables: | |
PROJECT: "amicia" | |
build-ci: | |
extends: .build-template | |
test: | |
extends: .test-template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include: | |
- '/gitlab-ci/template.yml' | |
variables: | |
PROJECT: "hugo" | |
build-ci: | |
extends: .build-template | |
test: | |
extends: .test-template |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment