BetaHuhn / deploy-to-vercel-action

🎬▲ Deploy your project to Vercel using GitHub Actions. Supports PR previews and GitHub deployments.
https://mxis.ch
MIT License
141 stars 71 forks source link

Error: Cannot read property 'login' of null #187

Open wottpal opened 2 years ago

wottpal commented 2 years ago

While deploying I get the following error, do you have any ideas?

Error: Cannot read property 'login' of null
Screen Shot 2022-06-21 at 01 26 07

The deploy script is basically copy'n'paste from the docs:

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Deploy to Vercel CI

on:
  workflow_dispatch:
  push:
    branches: [develop]

jobs:
  deploy:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, '[skip ci]')"
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Deploy
        uses: BetaHuhn/deploy-to-vercel-action@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
          VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
          VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
          VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
          PRODUCTION: false
sebastianst commented 2 years ago

May it be the case that the user whose token is used in the action also needs to have a fork of the repo?

It looks like in file github.js there's a client created with

    const client = github.getOctokit(GITHUB_TOKEN, { previews: [ 'flash', 'ant-man' ] })

which then operates under the user. Further down in the file, the property login is read from data obtained by calling client.repos.getCommit.

BetaHuhn commented 2 years ago

If anyone else is facing this issue, pinning the action to v1.9.0 is a temporary work around confirmed by @wottpal (https://github.com/yieldgate/yieldgate/pull/14#issuecomment-1162138808)

The issue might be caused by one of the last dependency updates which broke something internal, will take a closer look sometime this week.

luiscaro1 commented 2 years ago

I did the workaround and still getting the same error @BetaHuhn

Screen Shot 2022-07-09 at 2 51 14 PM
airtonix commented 2 years ago

yep also getting this error

airtonix commented 2 years ago

@BetaHuhn I'm not sure but would this be something to do with how you request the api features?

I'm having trouble finding documentation about this aspect on github.

  1. highlighted github.getOctokit and google searched it, resulting in this page one result: https://github.com/actions/toolkit/blob/main/packages/github/README.md
  2. following the link in there to https://octokit.github.io/rest.js/v18
  3. tried to follow the link in there about api previews: https://octokit.github.io/rest.js/v18#previews 👉🏻 https://docs.github.com/en/rest/overview/api-previews/
  4. land on a page that says nothing about api previews.
  5. ????
  6. confused.

Another thing is, does repos.getCommit actually return an author object containing a login property?

answer: looks like your pulling values from this shape:

{
  "commit": {
    "author": {
      "name": string
    }
  },
  "author": {
    "login": string
  }
}

but if you look at the JSONSchema of that data.author object, it says it can possibly be null.

image

Elindorath commented 2 years ago

I just encountered this issue with my team: some of my colleagues were able to deploy, others not. It drove me crazy! And I refused to believe that the author object could be null for no reason.

But I think I found it, and it is kind of dumb: I noticed that some of my colleagues used an email in their git configuration which was not added to their Github profile. And indeed, after rectification, everything went well!

Hope this can help!

BetaHuhnBot commented 1 year ago

⚠️ This issue has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

wottpal commented 1 year ago

@BetaHuhn should be reopened probably.

wottpal commented 1 year ago

I can fully confirm the finding by @Elindorath. It must be some coincidence that it suddenly worked for me that day.

Can you add this requirement to the Readme, please, @BetaHuhn?

BetaHuhnBot commented 1 year ago

⚠️ This issue has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

wottpal commented 1 year ago

WebTarantul commented 1 year ago

Fixed by adding an email and name to the .gitconfig file

krystiankedra commented 1 year ago

Hello, just update from my side, from few days we have the same issue:

Currently we are using BetaHuhn/deploy-to-vercel-action@v1.7.2

We were trying to change version for: BetaHuhn/deploy-to-vercel-action@v1.9.0 BetaHuhn/deploy-to-vercel-action@v1.9.12

but the issue was not resolved. What we tried as well is to set:

and it's not working as well. Is there any update about issue?

jerrywu001 commented 1 year ago

I got same issue

Finnepinnen commented 1 year ago

I used the proposal written by @Elindorath above

Run the following git config --local user.name "Name on Github" git config --local user.email "use_the_email_for_your_account@github.com"

Then made a small change to a random file and commited, pushed and then it worked!

Maybe this would solve your issues also? @krystiankedra and @jerrywu001

tmaihoff commented 11 months ago

Ran into the same problem on one machine.

Turned out I had a typo in the git config user.email.

Ran git config --local user.email "use_the_email_for_your_account" as @Finnepinnen suggested which fixed the issue