Skip to content
Snippets Groups Projects
Rules.yaml 3.34 KiB
Newer Older
# -*- mode: yaml; coding: utf-8 -*-
#
# 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 in a `$DEV_BRANCH`, by default `dev`
# - the pre-release fixes are done in a `$TESTING_BRANCH`, by default `testing`
# - the stable code is in `$STABLE_BRANCH`, by default `stable`
# - the release tags are prefixed with `$RELEASE_TAG_PREFIX`, by
#   default `release/`
#
# Usage:
# echo-a-message-for-stable:
#   extends: .on-stable
#     - echo "This is a job running only from stable branch"
#
# Optional variables:
# - `STABLE_BRANCH`: name of the stable branch
# - `TESTING_BRANCH`: name of the pre-release testing branch
# - `DEV_BRANCH`: name of the developpement branch
  RELEASE_TAG_PREFIX: release/
  HOTFIX_PREFIX: hotfix/
  TESTING_BRANCH: testing
  DEV_BRANCH: dev
  BUGFIX_PREFIX: bugfix/
  FEATURE_PREFIX: feature/

# This rules template should be used as the default rules.
# It select all branches except the stable one.
# We always exclude schedules.
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    - if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
      when: never
    - if: $CI_COMMIT_BRANCH
      when: on_success
# Select only branches that are not stable, testing or development.
# We always exclude schedules.
.on-branches:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    - if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
    - if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
      when: never
    - if: $CI_COMMIT_BRANCH == $DEV_BRANCH
      when: never
    - if: $CI_COMMIT_BRANCH
      when: on_success
# Select the developpment branch except for commits comming from `semantic-release`
# We always exclude schedules.
.on-dev:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    # Exclude $CI_DEFAULT_BRANCH of semantic-release commits
    - if: $CI_COMMIT_BRANCH == $DEV_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
    - if: $CI_COMMIT_BRANCH == $DEV_BRANCH
      when: on_success
# Select the pre-release testing branch except for commits comming from `semantic-release`
# We always exclude schedules.
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    # Exclude $CI_DEFAULT_BRANCH of semantic-release commits
    - if: $CI_COMMIT_BRANCH == $TESTING_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
      when: never
    - if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
      when: on_success

# Select the stable branch except for commits comming from `semantic-release`
# We always exclude schedules.
.on-stable:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    # Exclude $CI_DEFAULT_BRANCH of semantic-release commits
    - if: $CI_COMMIT_BRANCH == $STABLE_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
    - if: $CI_COMMIT_BRANCH == $STABLE_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