caprover / deploy-from-github

Apache License 2.0
60 stars 18 forks source link

Issues deploying #5

Closed Tam2 closed 1 year ago

Tam2 commented 1 year ago

I'm having some issues with deploying, it keeps giving me the below error:

(I do have a special path for captain-definition, it's just the hash error)

Preparing deployment to CapRover...

**** Warning ****
No captain-definition was found in main directory: unless you have specified a special path for your captain-definition, this build will fail!

Ensuring authentication...
Cannot find hash of last commit on branch "master".

This is how i've got my workflow set-up

name: API Tests
env:
  PORT: 4000
on:
  push:
    branches: [ "master" ]

jobs:
  build_and_test:
      runs-on: ubuntu-latest

      strategy:
        matrix:
          node-version: [18.x]

      steps:
        - uses: actions/checkout@v3
        - name: Use Node.js ${{ matrix.node-version }}
          uses: actions/setup-node@v3
          with:
            node-version: ${{ matrix.node-version }}
            cache: "npm"

        - name: Deploy Github repo to Caprover
          uses: caprover/deploy-from-github@main
          with:
            server: http://captain.domain.xxx
            token: <redacted>
            app: api-qa
            branch: master

        - name: Run API Tests
          uses: anthonyvscode/newman-action@v1
          with:
            collection: /tests/collection.json
            reporters: cli

        - name: Output summary to console
          run: echo ${{ steps.run-newman.outputs.summary }}
Tam2 commented 1 year ago

Added an extra step in to run git rev-parse master and it does output the hash

image
githubsaturn commented 1 year ago

Try running removing the branch variable, and just run this step before that:

git archive --format tar --output "./deploy.tar" master

Does this work?

Tam2 commented 1 year ago

I ended up just running the caprover deploy command directly in the wokflow and that worked

matheusfillipe commented 8 months ago

I think this shouldn't be closed. I had the same issue. The suggested commands will work in the CI:

git rev-parse master
git archive --format tar --output "./deploy.tar" master

work. Couldn't debug it further because the workaround is very simple:

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy App to CapRover
        run: |
          npm install -g caprover
          caprover deploy \
            --caproverUrl '${{ secrets.CAPROVER_SERVER }}' \
            --appToken '${{ secrets.APP_TOKEN }}' \
            --appName '${{ secrets.APP_NAME }}' \
            -b '${{ github.head_ref || github.ref_name }} '