Fix regular expression for commit message containing -draft

What does this MR do and why?

Fix the documentation on https://docs.gitlab.com/ee/ci/yaml/workflow.html where it said that the regular expression /-draft$/ would match commits that contain -draft. I think the expression should instead be /-draft/ (without the $).

Screenshots or screen recordings

When using the old regex with /-draft$/, jobs are run for all commits, even if they do contain -draft:

Screenshot of commits before using the updated regex

With the updated regex (without the $), commits that contain -draft don't create jobs: Screenshot of commits using the new regex

How to set up and validate locally

  1. Create a new .gitlab-ci.yml file in a repository.
  2. Add the following contents to the file:
workflow:
  rules:
    - if: $CI_COMMIT_MESSAGE =~ /-draft/
      when: never
    - when: always
publish:
  image: node:latest
  stage: deploy
  script: echo "Hello"
  1. Commit your changes.
  2. Create another commit with a commit message containing -draft and push.
  3. Check in Gitlab whether your pipeline has been run for the new commit. It should not have been run.
  4. Create another commit that doesn't contain -draft, push and check whether your pipeline has been run. It should have run.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Dean Malan

Merge request reports

Loading