From 5ad545475993947adbad0a4e03c5aa86b4ab48e5 Mon Sep 17 00:00:00 2001 From: Noritada Kobayashi Date: Sun, 10 Jul 2022 23:52:39 +0900 Subject: [PATCH 1/2] Note on the use of brackets in YAML flow sequences When `[` and/or `]` are used in a pattern within a YAML flow sequence, the pattern must be enclosed in quotes. Example statements in GitHub Actions workflows are as follows: - Syntax error: `branches: [ master, release/v[0-9].[0-9] ]` - Valid: `branches: [ master, 'release/v[0-9].[0-9]' ]` --- .../using-workflows/workflow-syntax-for-github-actions.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/content/actions/using-workflows/workflow-syntax-for-github-actions.md b/content/actions/using-workflows/workflow-syntax-for-github-actions.md index 64500c95e880..afa521d9b9f6 100644 --- a/content/actions/using-workflows/workflow-syntax-for-github-actions.md +++ b/content/actions/using-workflows/workflow-syntax-for-github-actions.md @@ -1046,7 +1046,7 @@ You can use special characters in path, branch, and tag filters. - `[]` Matches one character listed in the brackets or included in ranges. Ranges can only include `a-z`, `A-Z`, and `0-9`. For example, the range`[0-9a-z]` matches any digit or lowercase letter. For example, `[CB]at` matches `Cat` or `Bat` and `[1-2]00` matches `100` and `200`. - `!`: At the start of a pattern makes it negate previous positive patterns. It has no special meaning if not the first character. -The characters `*`, `[`, and `!` are special characters in YAML. If you start a pattern with `*`, `[`, or `!`, you must enclose the pattern in quotes. +The characters `*`, `[`, and `!` are special characters in YAML. If you start a pattern with `*`, `[`, or `!`, you must enclose the pattern in quotes. Also, when you use `[` and/or `]` in a pattern within a flow sequence, the pattern must be enclosed in quotes. ```yaml # Valid @@ -1055,6 +1055,12 @@ The characters `*`, `[`, and `!` are special characters in YAML. If you start a # Invalid - creates a parse error that # prevents your workflow from running. - **/README.md + +# Valid +- [ master, 'release/v[0-9].[0-9]' ] + +# Invalid - creates a parse error +- [ master, release/v[0-9].[0-9] ] ``` For more information about branch, tag, and path filter syntax, see "[`on..`](#onpushbranchestagsbranches-ignoretags-ignore)", "[`on..`](#onpull_requestpull_request_targetbranchesbranches-ignore)", and "[`on..paths`](#onpushpull_requestpull_request_targetpathspaths-ignore)." From 66c8f86f0e1eaa47183ccff7c1612e059d56a9a8 Mon Sep 17 00:00:00 2001 From: Lucas Costi Date: Mon, 22 Aug 2022 16:17:03 +1000 Subject: [PATCH 2/2] Edits for clarity --- .../workflow-syntax-for-github-actions.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/content/actions/using-workflows/workflow-syntax-for-github-actions.md b/content/actions/using-workflows/workflow-syntax-for-github-actions.md index beb865e3bae0..40ab7684fbb1 100644 --- a/content/actions/using-workflows/workflow-syntax-for-github-actions.md +++ b/content/actions/using-workflows/workflow-syntax-for-github-actions.md @@ -1037,21 +1037,23 @@ You can use special characters in path, branch, and tag filters. - `[]` Matches one character listed in the brackets or included in ranges. Ranges can only include `a-z`, `A-Z`, and `0-9`. For example, the range`[0-9a-z]` matches any digit or lowercase letter. For example, `[CB]at` matches `Cat` or `Bat` and `[1-2]00` matches `100` and `200`. - `!`: At the start of a pattern makes it negate previous positive patterns. It has no special meaning if not the first character. -The characters `*`, `[`, and `!` are special characters in YAML. If you start a pattern with `*`, `[`, or `!`, you must enclose the pattern in quotes. Also, when you use `[` and/or `]` in a pattern within a flow sequence, the pattern must be enclosed in quotes. +The characters `*`, `[`, and `!` are special characters in YAML. If you start a pattern with `*`, `[`, or `!`, you must enclose the pattern in quotes. Also, if you use a [flow sequence](https://yaml.org/spec/1.2.2/#flow-sequences) with a pattern containing `[` and/or `]`, the pattern must be enclosed in quotes. ```yaml # Valid -- '**/README.md' +branches: + - '**/README.md' # Invalid - creates a parse error that # prevents your workflow from running. -- **/README.md +branches: + - **/README.md # Valid -- [ master, 'release/v[0-9].[0-9]' ] +branches: [ main, 'release/v[0-9].[0-9]' ] # Invalid - creates a parse error -- [ master, release/v[0-9].[0-9] ] +branches: [ main, release/v[0-9].[0-9] ] ``` For more information about branch, tag, and path filter syntax, see "[`on..`](#onpushbranchestagsbranches-ignoretags-ignore)", "[`on..`](#onpull_requestpull_request_targetbranchesbranches-ignore)", and "[`on..paths`](#onpushpull_requestpull_request_targetpathspaths-ignore)."