JS-DevTools / npm-publish

GitHub Action to publish to NPM
https://jstools.dev/npm-publish
MIT License
620 stars 74 forks source link

Error: Input required and not supplied: token #31

Closed lastdoctor closed 1 year ago

lastdoctor commented 3 years ago

Hi, I have problem npm-publish.yml `on: push

jobs: publish: runs-on: ubuntu-latest steps:

and Here I have problem Run JS-DevTools/npm-publish@v1 with: registry: https://registry.npmjs.org/ package: package.json tag: latest dry-run: false check-version: true Error: Error: Input required and not supplied: token at Object.getInput (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/node_modules/@actions/core/lib/core.js:94:1) at main (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/src/action/index.ts:17:14) at Object.48 (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/src/action/index.ts:74:1) at __webpack_require__ (/webpack/bootstrap:21:1) at startup (/webpack/bootstrap:40:1) at /webpack/bootstrap:44:1 at Object.<anonymous> (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/dist/index.js:50:10) at Module._compile (internal/modules/cjs/loader.js:959:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) at Module.load (internal/modules/cjs/loader.js:815:32)

trivikr commented 3 years ago

I'm receiving the same error.

Failed GitHub Action for reference: https://github.com/trivikr/test-postinstall-node-version-check/actions/runs/727995782

Error:

Error: Error: Input required and not supplied: token
    at Object.getInput (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/node_modules/@actions/core/lib/core.js:94:1)
    at main (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/src/action/index.ts:17:14)
    at Object.48 (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/src/action/index.ts:74:1)
    at __webpack_require__ (/webpack/bootstrap:21:1)
    at startup (/webpack/bootstrap:40:1)
    at /webpack/bootstrap:44:1
    at Object.<anonymous> (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/dist/index.js:50:10)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)

Configuration for reference:

name: push

on:
  push:
    branches: [main]

jobs:
  publish:
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v2
      - uses: JS-DevTools/npm-publish@v1
        env:
          token: ${{ secrets.NPM_AUTH_TOKEN }}

I verified that NPM_AUTH_TOKEN GitHub secret is present, as the same secret was successfully used by https://github.com/marketplace/actions/automated-releases-for-npm-packages prior to testing npm-publish

ayush-goyal commented 3 years ago

I'm having this same issue as well ^

Nurutomo commented 3 years ago

same error with this configuration

name: npm-publish
on: "workflow_dispatch"
jobs:
  npm-publish:
    name: npm-publish
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@master
    - name: Set up Node.js
      uses: actions/setup-node@master
      with:
        node-version: 14.0.0
    - id: publish
      uses: JS-DevTools/npm-publish@v1
      with:
        token: ${{ secrets.NPM_TOKEN }}

The Error Log: https://github.com/Nurutomo/xteam-api/runs/2812373560?check_suite_focus=true

thegiantbeast commented 2 years ago

The workaround I found to work is to run env as a step before this action. Like so:

    - name: List Github Actions
       run: env
    - uses: JS-DevTools/npm-publish@v1
      with:
        token: ${{ secrets.NPM_TOKEN }}

It seems there's some race condition where the action tries to read process.env, but the variables were not yet set up? πŸ€” It sounds weird this explanation, but it's the closest thing I can think about

UPDATE: I was wrong, this didn't actually workaround the issue but strange given that I tried a couple of times to be sure it wasn't a false positive. πŸ€”

thegiantbeast commented 2 years ago

@JamesMessinger any thoughts on this one? πŸ™‡

OskarDamkjaer commented 2 years ago

I ran into this issue as well, my problem was not setting the environment key, that's why the publish step didn't have access to {{ secrets.NPM_TOKEN }}. More info in the github action docs here πŸ˜„

mcous commented 1 year ago

Hi all, these all look like various misconfiguration issues. I'm going to close this issue since links to various action run logs posted have expired so reproduction would be overly difficult. If anyone is still experiencing issues, please feel free to open a new issue!

If you're interested in seeing a working configuration for this action, you can take a look at: https://github.com/viamrobotics/prime/blob/main/.github/workflows/publish.yml