Set log in credential to github actions

I’m trying to use GitHub action that uploads the snap to snap store, but I cant log in to snapcraft in actions. I’ve created the log in scripts using this

snapcraft export-login --snaps *snap_name* snap.login

The snap.login file looks like this

macaroon = ****
unbound_discharge = ****
email = ****

I’ve copy pasted the content of the above file in github action token as SNAP_TOKEN and my action looks like this

      - name: upload to snap
        run: |
          sudo snap install snapcraft --classic
          echo ${{secrets.SNAP_TOKEN}} | snapcraft login --with -
          snapcraft upload --release=stable dist/*.snap

But the action crash with this error

/home/runner/work/_temp/ line 3: macaroon: command not found
Error: Process completed with exit code 127.

What am I doing wrong here and how to solve this?

To get base64 encoded output, run

snapcraft export-login --snaps <snap-name> -

Or base64 encode the file contents and use that in your env.