Refactor duplicated rules sections in CI/CD templates
The rules sections in the CI/CD templates currently contain a lot of duplicated code. This should be refactored to reduce redundancy, improve maintainability, and make the templates easier to extend in the future.