caprover / caprover-cli

Command Line Interface for https://github.com/caprover/caprover
72 stars 40 forks source link

Error "Cannot find hash of last commit on branch" #119

Closed louis-l closed 2 years ago

louis-l commented 2 years ago

Hi there,

I have been using AlexxNB/caprover-action@v1 to auto deploy on push for ages, but today it stops working. I checked the Github action log and the last log was Cannot find hash of last commit on branch "master".

Here is the screenshot: Screen Shot 2022-04-19 at 9 03 39 am

I googled and found nothing exception this code: https://github.com/caprover/caprover-cli/blob/master/src/utils/ValidationsHandler.ts#L181

Can anyone shed some light here?

Cheers,

githubsaturn commented 2 years ago

I'd suggest you post the issue here: https://github.com/AlexxNB/caprover-action

louis-l commented 2 years ago

I thought about it, but then I check that action and its only job is to run caprover deploy ... command. So I thought it had something to do with the Caprover CLI.

githubsaturn commented 2 years ago

There is more to it. What's version of git? What environment it's running in? etc.

Can you reproduce it locally using caprover deploy?

louis-l commented 2 years ago

I just tested caprover deploy locally and it worked.

This is my deploy yml file:

name: CapRover Deployment
on:
  push:
    branches:
      - master
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: master
      - name: CapRover Deploy
        uses: AlexxNB/caprover-action@v1
        with:
          server: ${{secrets.CAPROVER_SERVER}}
          password: ${{secrets.CAPROVER_PASSWORD}}
          appname: ${{secrets.CAPROVER_APPNAME}}
          branch: master
      - name: Slack Notification
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        uses: act10ns/slack@v1.5.0
        with:
          status: ${{ job.status }}
        if: always()

Again, it was working fine. Just today it stops working.

I checked AlexxNB/caprover-action@v1 repo and it has not been changed in 2 years.

githubsaturn commented 2 years ago

Then it's something that changed on Github runners. Perhaps a different git version. Requires debugging. Try running this in your github runner and see what it prints:

git rev-parse master
louis-l commented 2 years ago

This is my test:

name: CapRover Deployment
on:
  push:
    branches:
      - master
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: master
      - name: Test git command 🧪
        run: git rev-parse master
      - name: CapRover Deploy
        uses: AlexxNB/caprover-action@v1
        with:
          server: ${{secrets.CAPROVER_SERVER}}
          password: ${{secrets.CAPROVER_PASSWORD}}
          appname: ${{secrets.CAPROVER_APPNAME}}
          branch: master
      - name: Slack Notification
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        uses: act10ns/slack@v1.5.0
        with:
          status: ${{ job.status }}
        if: always()

and here is the output: image

githubsaturn commented 2 years ago

Hmm.. that's exactly what caprover deploy does... Not sure what's happening here https://github.com/caprover/caprover-cli/blob/3f93fb79e3fba0afc7bbc48a01edb69103db3f05/src/utils/ValidationsHandler.ts#L171-L180

louis-l commented 2 years ago

P/S: here is the logs from Github action when building the AlexxNB/caprover-action@v1:

image

Seems like its running the latest caprover 2.2.3

louis-l commented 2 years ago

Yeh, that's weird. Is there anything I can do to/provide to help?

githubsaturn commented 2 years ago

You'd have to fork the action that you're using and debug it by running git rev-parse master before caprover deploy

louis-l commented 2 years ago

@githubsaturn

I created a folk here: https://github.com/louis-l/caprover-action/blob/master/run.sh

However, I could not get it to print out the result.

This is the output: Screen Shot 2022-04-19 at 12 45 18 pm

Googled around and could not find a solution. Can you give advice please?

louis-l commented 2 years ago

I managed to update Dockerfile from node:12-alpine to node:14-alpine and added CMD git rev-parse master. image

and here is the output: Test-Github-action-·-louis-l-Vaocher-API-0db2739

Still not working and still could not get it to print out the git command result.

githubsaturn commented 2 years ago

Your dockerfile here is wrong: image

Move the git rev-parse master line to the run.sh file, not the dockerfile.

louis-l commented 2 years ago

It was in run.sh before but I could not get it to print the output out to Github Action console.

This is what I tried in run.sh:

git rev-parse master

caprover deploy -h $INPUT_SERVER -p $INPUT_PASSWORD -b $INPUT_BRANCH -a $INPUT_APPNAME 

and the result was posted in https://github.com/caprover/caprover-cli/issues/119#issuecomment-1101939084

githubsaturn commented 2 years ago

Then you'll have to find out why git rev-parse master doesn't print anything on the github runner. At that point, it hasn't even reached CapRover code. That aside, it's very bizarre that it doesn't print anything, not even an error.

louis-l commented 2 years ago

Thanks for your time @githubsaturn I gave up here 😔 Dont know where to look.

githubsaturn commented 2 years ago

There is also floms/action-caprover - I see some people using this. Try it out, it might work.

louis-l commented 2 years ago

Thanks @githubsaturn

I tried that action and it worked 😯 Presumably, the issue lies in the OS and git version.

Anw, all good now. Thanks for your time again.