Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: redundant event names in expressions are errors #69

Open
webignition opened this issue Nov 4, 2021 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@webignition
Copy link

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.

@rhysd
Copy link
Owner

rhysd commented Nov 18, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants