Commit 5d250339 authored by Clement Bois's avatar Clement Bois
Browse files

feat: modular workflow rules

parent cd07de25
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -108,14 +108,24 @@ spec:
      description: OpenShift API url for production env (only define to override default)
      default: ''
---
workflow:
  rules:
# default workflow rules: Merge Request pipelines
.tbc-workflow-rules:
  # prevent MR pipeline originating from production or integration branch(es)
  skip-back-merge:
    - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ $PROD_REF || $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ $INTEG_REF'
      when: never
  # on non-prod, non-integration branches: prefer MR pipeline over branch pipeline
  # ⚠️ can't be used with next rule
  prefer-mr-pipeline:
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
      when: never
  # prefer branch pipeline over MR pipeline
  # ⚠️ can't be used with previous rule
  prefer-branch-pipeline:
    - if: $CI_MERGE_REQUEST_ID
      when: never
  # extended "[skip ci]" behavior
  extended-skip-ci:
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*tag(,[^],]*)*\]/" && $CI_COMMIT_TAG'
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*branch(,[^],]*)*\]/" && $CI_COMMIT_BRANCH'
@@ -130,6 +140,15 @@ workflow:
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*dev(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
      when: never
  # TBC default rules (MR workflow policy)
  default:
    - !reference [.tbc-workflow-rules, skip-back-merge]
    - !reference [.tbc-workflow-rules, prefer-mr-pipeline]
    - !reference [.tbc-workflow-rules, extended-skip-ci]

workflow:
  rules:
    - !reference [.tbc-workflow-rules, default]
    - when: always

variables: