Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find hash of last commit on branch "main" #4

Open
Alwinator opened this issue Apr 19, 2022 · 8 comments
Open

Cannot find hash of last commit on branch "main" #4

Alwinator opened this issue Apr 19, 2022 · 8 comments

Comments

@Alwinator
Copy link

You caprover action worked great for month, but for one week it does not work with the following exception:

Preparing deployment to CapRover...

**** Warning ****
No captain-definition was found in main directory: falling back to Dockerfile.

Ensuring authentication...
Cannot find hash of last commit on branch "main".
@Alwinator
Copy link
Author

I think it could be fixed by rebuilding because then npm installs the latest Caprover CLI which fixed the bug.

@jfm-wcs
Copy link

jfm-wcs commented Apr 23, 2022

Hi, got exactly the same issue. Deployment to caprover fails.
Some npm warning from previous step Build AlexxNB/caprover-action@v1 could they be involved ?

@Alwinator
Copy link
Author

I used a workaround, it might not be as fast, but it always uses the latest version. Replace the action:

- name: Caprover Deploy
  uses: AlexxNB/caprover-action@v1
  with:
     server: 'https://example.com'
     password: '${{ secrets.CAPROVER_PASSWORD }}'
     appname: 'myapp'
     branch: 'main'

With the following code that installs the Caprover CLI in the pipeline and deploys your app.

- name: Set up npm
  uses: actions/setup-node@v2
  with:
     node-version: '14'

- name: Install caprover
  run: npm install -g caprover

- name: Caprover Deploy
  run: caprover deploy -h 'https://example.com' -p '${{ secrets.CAPROVER_PASSWORD }}' -b 'main' -a 'myapp'

@jfm-wcs
Copy link

jfm-wcs commented Apr 23, 2022

Works fine! Not that slow, thanks!

@Alwinator
Copy link
Author

Alwinator commented Apr 23, 2022

After a little investigation, the bug is caused by this line. The problem is that the Github checkout action only pulls the latest hash which causes an issue with git rev-list. It can be fixed by adding fetch-depth: 0, see git-rev-list-not-working-inside-github-action. For some reason, it also works when using Ubuntu instead of Alpine, but that makes it even slower.

 uses: actions/checkout@v2
 with:
   fetch-depth: 0

However,

I realized after benchmarking that installing the Caprover CLI in the pipeline as mentioned in my comment before is a much better solution than using this action because it only takes 13 seconds. This action takes 28 seconds and it is already based on alpine, so it cannot be improved a lot.

13 second solution (without action):

- name: Set up npm
  uses: actions/setup-node@v2
  with:
     node-version: '14'

- name: Install caprover
  run: npm install -g caprover

- name: Caprover Deploy
  run: caprover deploy -h 'https://example.com' -p '${{ secrets.CAPROVER_PASSWORD }}' -b 'main' -a 'myapp'

@Teemu
Copy link

Teemu commented Nov 10, 2022

Thanks @Alwinator !

therebelrobot added a commit to therebelrobot/simple-blog-server that referenced this issue Mar 14, 2023
@kristijanPetr
Copy link

After two days of trial and error and trying above methods, I couldn't get to work.
Finnaly found solution, actually you would need to checkout to the branch that is referenced.

 - name: Checkout to branch
        run: |
          git fetch origin ${{ github.head_ref }}
          git checkout ${{ github.head_ref }}

@anhdh0o0
Copy link

econd solution (without action):

- name: Set up npm
  uses: actions/setup-node@v2
  with:
     node-version: '14'

Thank you for your instructions, I followed it and it worked.
Really thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants