GitHub Actions Expression
Match `${{ expression }}` interpolations used in GitHub Actions workflow YAML.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("\\$\\{\\{\\s*([^}]+?)\\s*\\}\\}", "g");
const input = "if: ${{ github.actor == 'octocat' }}";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"\$\{\{\s*([^}]+?)\s*\}\}")
input_text = "if: ${{ github.actor == 'octocat' }}"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\$\{\{\s*([^}]+?)\s*\}\}`)
input := `if: ${{ github.actor == 'octocat' }}`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
\$\{\{\s*([^}]+?)\s*\}\} (flags: g)Raw source: \$\{\{\s*([^}]+?)\s*\}\}
How it works
Examples
Input
if: ${{ github.actor == 'octocat' }}Matches
${{ github.actor == 'octocat' }}
Input
run: echo ${{ secrets.NPM_TOKEN }} | npm publishMatches
${{ secrets.NPM_TOKEN }}
Input
no expressionsNo match
—Common use cases
- •Linting workflow files for unsafe expressions
- •Detecting committed secret references
- •Migrating between GitHub Actions and other CI providers
- •Documentation generation from workflow YAML
Related patterns
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.
AWS S3 Bucket Name
IdentifiersValidate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
Docker Image Tag
IdentifiersMatch Docker image references with an explicit tag — e.g. nginx:1.21, mycorp/service:v2.3.1.
Git Commit SHA
IdentifiersMatch Git commit hashes, both short (7 chars) and full (40 chars) forms.