Add rules support for configuring cache settings dynamically
Problem to solve
Use different cache key for the same job depending on dynamic factors (mostly environment variables).
Proposal
A way to control sub-tags of cache
key using rules/conditionals
cache:
key: 'cache-key-ce'
paths:
- 'global_dir/'
rules:
- if: '$ee == true'
key: 'cache-key-ee'
paths:
- 'global_dir/'
- 'ee_specific_dir/'
- if: '$CI_COMMIT_TAG =~ /^.*ee\.\d.*$/'
key: 'cache-key-ee'
paths:
- 'global_dir/'
- 'ee_specific_dir/'
- if: '$CI_COMMIT_BRANCH =~ /^.*-ee$/'
key: 'cache-key-ee'
paths:
- 'global_dir/'
- 'ee_specific_dir/'
- if: '$CI_COMMIT_TAG =~ $AUTO_DEPLOY_TAG_REGEX'
key: 'cache-key-ee'
paths:
- 'global_dir/'
- 'ee_specific_dir/'