Skip to content

Docs: if: github.event == 'push' doesn't work, it should be github.event_name #950

Description

@miaotony

Describe the bug

I found a documentation bug when I edited one of my GitHub Action configuration files.

At the end of the documentation, we could see the Running steps or jobs conditionally section, which told that we can specify a condition in the if: property based on the event name.

bug

However, when I used if: github.event == 'push' to do such thing, the action didn't run this step.

To Reproduce
Steps to reproduce the behavior:

  1. Go to one of the action configuration files.
  2. Run a step with if: github.event == 'push'.
  3. When push, this step doesn't run.

Expected behavior
Run a specific step when push events happen.

Runner Version and Platform

The latest version.
Ubuntu-latest (No matter what OS actually)

What's not working?

I tried to solve it by referring to the documentation Contexts and expression syntax for GitHub, in which I found that github.event was an object and github.event_name was a string.

So I tested them using codes like these.

      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"

By dumping the github context, we can see that github.event is actually an object and github.event_name is a string that we want.

Finally, I change the code from github.event to github.event_name, and that step works successfully.

Solution

Update the document on the right of the online editor.

if: github.event == 'push' should be if: github.event_name == 'push'.

Thank you!

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions