Doc of example usage of CI_COMMIT_REF_PROTECTED wrong
Problem to solve
The documentation example using CI_COMMIT_REF_PROTECTED variable for CI/CD Workflow Definition is wrong. The example assumes that CI_COMMIT_REF_PROTECTED is empty, if not true, but the variable is contains false. Therefore duplicate pipelines are created if using the example as is.
See https://docs.gitlab.com/ee/ci/yaml/workflow.html#git-flow-with-merge-request-pipelines
Further details
Output from a simple CI/CD of a blank project in selfhosted Gitlab version 15.1.2-ee:
$ echo "CI_PIPELINE_SOURCE=$CI_PIPELINE_SOURCE"
CI_PIPELINE_SOURCE=merge_request_event
$ echo "CI_COMMIT_REF_PROTECTED=$CI_COMMIT_REF_PROTECTED"
CI_COMMIT_REF_PROTECTED=false
Proposal
The example should test CI_COMMIT_REF_PROTECTED explicitly for true:
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_REF_PROTECTED == "true"