Add additional matcher types to `rules:`
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=29742)
</details>
<!--IssueSummary end-->
### Problem to solve
The new `rules` syntax implemented in https://gitlab.com/gitlab-org/gitlab-ce/issues/60085 provides only an `if:` matcher that can operate on variables. There are a few common matching criteria that it may be nice to provide syntactic sugar for.
### Intended users
Software Developers
### Proposal
Add the following new matcher types that implement an easier to understand version of the `if:` element.
#### `branch:` matcher
```yaml
rules:
- branch: master # match by string, the branch name `master`
- branch: /stable-.*/ # match by regexp, the branch name
- branch: yes # accept every reference that is branch
# yes is a boolean type (equal to true), so it is different than string
# `any` could be used, but then it would be magic keyword from string
```
#### `tag:` matcher
```yaml
rules:
- tag: v1.0 # match by string, the tag name `master`
- tag: /tag-.*/ # match by regexp, the tag name
- tag: yes # accept every reference that is tag
# yes is a boolean type (equal to true), so it is different than string
# `any` could be used, but then it would be magic keyword from string
```
#### `project:` matcher
Matches a target project for merge request pipelines, or project for all other types of pipelines,.
```yaml
rules:
- project: gitlab-org/gitlab-ce # match by string, the project name
```
#### `source_project:` matcher
Matches source project, the source project makes sense in context of merge request pipelines, when they are created from fork.
```yaml
rules:
- source_project: ayufan/gitlab-ce # match by string, the source project name of MR pipeline
```
#### `source:` matcher
The source of action [the special keywords of only:refs]: (https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic):
```yaml
rules:
- source: web
- source: push
- source: trigger
- source: schedule
- source: pipeline
- source: chat
- source: api
- source: merge-request
```
#### `merge-request:` matcher
Matches all pipelines that are for merge requests, the merge-request: matches the source branch name.
```yaml
rules:
- merge-request: /security-.*/ # we target all merge requests that are created from `security-.*`
- merge-request: yes # similar to branch/tag, the `true` matches all merge-requests
```
If you would like to support matching merge requests targeting given branch, you would join that with `branch: master` as follows:
```yaml
rules:
- merge-request: /security-.*/ # we target all merge requests that are created from `security-.*`
branch: master # match merge requests targeting `master` branch
```
### Permissions and Security
<!-- What permissions are required to perform the described actions? Are they consistent with the existing permissions as documented for users, groups, and projects as appropriate? Is the proposed behavior consistent between the UI, API, and other access methods (e.g. email replies)? -->
### Documentation
<!-- See the Feature Change Documentation Workflow https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html
Add all known Documentation Requirements here, per https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#documentation-requirements -->
### Testing
<!-- What risks does this change pose? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing? See the test engineering process for further guidelines: https://about.gitlab.com/handbook/engineering/quality/guidelines/test-engineering/ -->
### What does success look like, and how can we measure that?
<!-- Define both the success metrics and acceptance criteria. Note that success metrics indicate the desired business outcomes, while acceptance criteria indicate when the solution is working correctly. If there is no way to measure success, link to an issue that will implement a way to measure this. -->
### Links / references
<!-- triage-serverless v3 PLEASE DO NOT REMOVE THIS SECTION -->
*This page may contain information related to upcoming products, features and functionality.
It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes.
Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.*
<!-- triage-serverless v3 PLEASE DO NOT REMOVE THIS SECTION -->
issue