Error when comparing github.actor to string in if statement

Hey,

I’m getting an error when trying to compare github.actor to my username in the if statement.

This is the error I’m getting:

The workflow is not valid. .github/workflows/compare.yml (Line: 18, Col: 11): Unexpected symbol: '"my_username"'. Located at position 17 within expression: github.actor == "my_username"

My goal is to:

* only run action if my user pushed the code

name: Compare user to actor

on:
  push:


jobs:

  build:
    name: Compare user to actor
    runs-on: ubuntu-latest
    steps:

    - name: Check out code
      uses: actions/checkout@v2

    - name: Actor
      if: github.actor == "my_username"
      env:
        ACTOR: ${{ github.actor }}
        PUSHER: ${{ github.event.pusher.name }}
      run: |
        echo "$ACTOR"
        echo "$PUSHER"

Hi @danielinclouds ,

The error is due to double quotes are used for username, please use single quote, code as below:

- name: Actor
        if: github.actor ==<font color="#FF0000">'</font>weide-zhou<font color="#FF0000">' <font color="#000000"># use '' to enclose username</font></font> env:
          ACTOR: ${{ github.actor }}
          PUSHER: ${{ github.event.pusher.name }}
        run: |
          echo "$ACTOR"
          echo "$PUSHER"

singalquote.png

Thanks.

Thanks, that fixed my problem.