actionlint
actionlint copied to clipboard
Feature request: redundant event names in expressions are errors
An expression can reference an event name, for example if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
.
As the events to which a workflow responds are always present at the top of the workflow, it should be possible to determine when an event name within an expression is redundant.
Take the following workflow as an example:
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
uses: actions/checkout@v2
In this example, the workflow only responds to push
events, however the expression refers to both push
and pull_request
events. This suggests that something is wrong somewhere. Either the workflow should be responding also to pull_request
events or the expression needs to be changed to remove the second part of the expression.
I'm sorry for delay of response. And thank you for the suggestion.
Since actionlint's type system does not have union types like "push" | "pull_request"
, currently this cannot be solved by type checker.
However I think it is possible to add special check to github.event_name
.