Skip to content

Commit

Permalink
do not allow contexts listed in 'Available Contexts' page
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Dec 26, 2024
1 parent d3399fe commit d5c1d55
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions expr_sema.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,27 +462,27 @@ func (sema *ExprSemanticsChecker) SetContextAvailability(avail []string) {
}

func (sema *ExprSemanticsChecker) checkAvailableContext(n *VariableNode) {
if len(sema.availableContexts) == 0 {
return
}

ctx := strings.ToLower(n.Name)
for _, c := range sema.availableContexts {
if c == ctx {
return
}
}

s := "contexts are"
if len(sema.availableContexts) == 1 {
s = "context is"
var notes string
switch len(sema.availableContexts) {
case 0:
notes = "no context is available here"
case 1:
notes = "available context is " + quotes(sema.availableContexts)
default:
notes = "available contexts are " + quotes(sema.availableContexts)
}
sema.errorf(
n,
"context %q is not allowed here. available %s %s. see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details",
"context %q is not allowed here. %s. see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details",
n.Name,
s,
quotes(sema.availableContexts),
notes,
)
}

Expand Down

0 comments on commit d5c1d55

Please sign in to comment.