Skip to content
Snippets Groups Projects
Commit 71a1ac4f authored by Daniel Dehennin's avatar Daniel Dehennin
Browse files

Merge branch 'feature/implement-gitflow-style-rules' into 'master'

ci(rules): define git-flow style rules

See merge request !7
parents ab76131e e8e12e8f
No related branches found
No related tags found
1 merge request!7ci(rules): define git-flow style rules
Pipeline #6968 passed
......@@ -3,7 +3,7 @@
---
commitlint:
stage: lint
extends: .default_rules
extends: .not-on-prod
image: 'hub.eole.education/eole/commitlint:latest'
before_script:
# Add `upstream` remote to get access to `upstream/master`
......
# -*- coding: utf-8 -*-
# -*- mode: yaml; coding: utf-8 -*-
# vim: ft=yaml
#
# Define variables and rules to work in a git-flow like workflow
# See https://nvie.com/posts/a-successful-git-branching-model/
#
# - the developpment is done un a `$DEV_BRANCH`, by default `develop`
# - the production code is in `$PROD_BRANCH`, by default `master`
# - the release tags are prefixed with `$RELEASE_TAG_PREFIX`, by
# default `release/`
#
# Usage:
# echo-a-message-for-prod:
# extends: .on-prod
# script:
# - echo This is a job running only from production branch
#
# Optional variables:
# - `PROD_BRANCH`: name of the production branch
# - `DEV_BRANCH`: name of the developpement branch
---
###############################################################################
# Define rules templates to be used by jobs
###############################################################################
# Rules used by default
.default_rules:
variables:
PROD_BRANCH: master
RELEASE_TAG_PREFIX: release/
BUGFIX_PREFIX: bugfix/
DEV_BRANCH: develop
FEATURE_PREFIX: feature/
HOTFIX_PREFIX: hotfix/
# This rules template should be used as the default rules.
# It select all branches except the production one.
# We always exclude schedules.
.not-on-prod:
rules:
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_BRANCH == $PROD_BRANCH
when: never
# All branches
- if: $CI_COMMIT_BRANCH
when: on_success
# Build on branches and release tag push
.build_rules:
# Select only branches that are not production or development.
# We always exclude schedules.
.on-branches:
rules:
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_BRANCH == $PROD_BRANCH
when: never
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: never
- if: $CI_COMMIT_TAG
when: never
# All branches
- if: $CI_COMMIT_BRANCH
# Only for protected release tags
- if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
when: on_success
# Run semantic release only on $CI_DEFAULT_BRANCH except for release commits
.release_rules:
# Select the developpment branch except for commits comming from `semantic-release`
# We always exclude schedules.
.on-dev:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: on_success
# Run on published release tags
.tag_rules:
# Select the production branch except for commits comming from `semantic-release`
# We always exclude schedules.
.on-prod:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude semantic-release commits on $PROD_BRANCH
- if: $CI_COMMIT_BRANCH == $PROD_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $PROD_BRANCH
when: on_success
# Select the protected release tags
# We always exclude schedules.
.on-release-tag:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Only for protected release tags
- if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
when: on_success
...
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment