percy / storybook-action

[Deprecated] A GitHub action to run Percy with Storybook
https://docs.percy.io/docs/github-actions#section-storybook-action
MIT License
11 stars 5 forks source link

Error: The PERCY_TOKEN environment variable is missing for forked builds #4

Closed amowu closed 4 years ago

amowu commented 4 years ago

I have added PERCY_TOKEN to the GitHub repo Settings > Secrets.

But I got a wrong results:

info => Output directory: /home/runner/work/hahow-design/hahow-design/storybook-static
/usr/local/bin/npx percy-storybook
Error:  Error: The PERCY_TOKEN environment variable is missing.
    at Object._callee$ (/home/runner/work/hahow-design/hahow-design/node_modules/@percy/storybook/lib/cli.js:84:19)
    at tryCatch (/home/runner/work/hahow-design/hahow-design/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/home/runner/work/hahow-design/hahow-design/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.<computed> [as next] (/home/runner/work/hahow-design/hahow-design/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/home/runner/work/hahow-design/hahow-design/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /home/runner/work/hahow-design/hahow-design/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F (/home/runner/work/hahow-design/hahow-design/node_modules/core-js/library/modules/_export.js:36:28)
    at Object.<anonymous> (/home/runner/work/hahow-design/hahow-design/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Object.run (/home/runner/work/hahow-design/hahow-design/node_modules/@percy/storybook/lib/cli.js:143:17)
    at Object.<anonymous> (/home/runner/work/hahow-design/hahow-design/node_modules/@percy/storybook/bin/percy-storybook.js:4:4)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at /usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14
##[error]The process '/usr/local/bin/npx' failed with exit code 1
##[error]Node run failed with exit code 1

This is my config file:

name: Percy
on: [push, pull_request]
jobs:
  default:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Install
        run: npm i
      - name: Percy Test
        uses: percy/storybook-action@v0.1.1
        env:
          PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
squidsoup commented 4 years ago

I'm seeing this too, and the PERCY_TOKEN secret is set.

/usr/local/bin/npx percy-storybook
Error:  Error: The PERCY_TOKEN environment variable is missing.
    at Object._callee$ (/home/runner/work/react-components/react-components/node_modules/@percy/storybook/lib/cli.js:84:19)
    at tryCatch (/home/runner/work/react-components/react-components/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/home/runner/work/react-components/react-components/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.<computed> [as next] (/home/runner/work/react-components/react-components/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/home/runner/work/react-components/react-components/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /home/runner/work/react-components/react-components/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F (/home/runner/work/react-components/react-components/node_modules/babel-runtime/node_modules/core-js/library/modules/_export.js:36:28)
    at Object.<anonymous> (/home/runner/work/react-components/react-components/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Object.run (/home/runner/work/react-components/react-components/node_modules/@percy/storybook/lib/cli.js:143:17)
    at Object.<anonymous> (/home/runner/work/react-components/react-components/node_modules/@percy/storybook/bin/percy-storybook.js:4:4)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at /usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14
##[error]The process '/usr/local/bin/npx' failed with exit code 1

Weirdly, we had one PR pass without issue, but subsequent PRs are now failing with this.

squidsoup commented 4 years ago

I suspect this is due to the PR coming from a forked repository. Any suggestions for working around this, or is this a fundamental limitation of github actions currently?

squidsoup commented 4 years ago

Relevant discussion here. For the meantime we've amended our yaml to:

on: [push]

A shame that we can't gate PRs on percy.

Robdel12 commented 4 years ago

Ah, right, that would do it! Currently there's no way to expose secrets to forks for GitHub actions. If that's something that's required you'd have to switch to something like CircleCI until GitHub implements it.

Robdel12 commented 4 years ago

@amowu were you also having the same issue (the token missing on forked PR builds)? If so I'll rename the issue title (for future search ability) and then close out 👍