AkhileshNS / heroku-deploy

A simple github action that dynamically deploys an app to heroku
MIT License
981 stars 259 forks source link

heroku: not found #65

Closed patrickmead closed 3 years ago

patrickmead commented 3 years ago

I’m trying to use heroku-deploy. My build fails because heroku is not found. My understanding is that the heroku-cli is preinstalled.

/bin/sh: 1: heroku: not found
Error: Error: Command failed: heroku login

I uninstalled heroku-cli then installed heroku globally via npm. That didn’t work. Then I tried adding heroku to my package.json. That didn’t work.

Any suggestions are greatly appreciated. Thank you.

AkhileshNS commented 3 years ago

You're right in that the Heroku Cli should be installed by default. Could you provide your buildlog and workflow file if possible?

patrickmead commented 3 years ago

Thank you very much, @AkhileshNS

`# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node

For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Dendra API CI

on: push: branches: [ main ] pull_request: branches: [ main ]

jobs: build: runs-on: ubuntu-latest container: node:10.18-jessie services: postgres: image: postgres env: POSTGRES_PASSWORD: postgres options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports:

Maps tcp port 5432 on service container to the host

      - 5432:5432
strategy:
  matrix:
    node-version: [14.x]

steps:
# - name: setup ssh
#   uses: webfactory/ssh-agent@v0.4.1
#   with:
#     ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Set up node.js v${{ matrix.node-version }}
  uses: actions/setup-node@v2
  with:
    node-version: ${{ matrix.node-version }}

- name: Clone Dendra Repo
  uses: actions/checkout@v2

- name: Setup NPM Private Github Packages
  run: |
    echo "@general-galactic:registry=https://npm.pkg.github.com" > .npmrc
    echo "//npm.pkg.github.com/:_authToken=${{secrets.GH_NPM_REGISTRY_TOKEN}}" >> .npmrc
    echo "always-auth=true" >> .npmrc

# - name: Print working directory
#   run: pwd

# - name: Print npm info
#   run: cat .npmrc

# - name: Print env
#   run: env

# - name: git clone a private repo
#   run: git clone --depth=1 -q -b master git://github.com/general-galactic/hapi-swagger.git ./crap && ls ./crap

# - name: npm install from a private github repo
#   run: npm i git://github.com/general-galactic/hapi-swagger && ls node_modules/hapi-swagger

# - name: npm install private github package
#   run: npm i @general-galactic/dendra-jwt && ls node_modules/@general-galactic/dendra-jwt

# - name: verify ssh key works
#   run: ssh -T git@github.com

# - name: Authenticate to Github Package Registry for private NPM modules
#   run: echo "//npm.pkg.github.com/:_authToken=${{secrets.GH_NPM_REGISTRY_TOKEN}}" >> .npmrc

- name: Install Dendra API Dependencies
  # Skiping post-install scripts here, as a malicious script could steal NODE_AUTH_TOKEN.
  # running bcrypt separately since it requires a post-install script
  run: npm ci

- name: Install hapi-swagger
  run: npm i git://github.com/general-galactic/hapi-swagger

- name: Lint Dendra API
  run: npm run lint:ci

- name: Run Tests
  env:
    DATABASE_URL: postgres://postgres:postgres@postgres:5432/dendra-test # the github postgres container chose all the defaults.
  run: npm test

- name: Deploy to Heroku
  uses: akhileshns/heroku-deploy@v3.10.9 
  with:
      heroku_api_key: ${{secrets.HEROKU_API_KEY}}
      heroku_app_name: "dendra-api-stage" 
      heroku_email: "patrick@generalgalactic.io"  
      justlogin: true
      remote_branch: main

- name: Notify Slack Failure
  if: failure()
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
  uses: voxmedia/github-action-slack-notify-build@v1
  with:
    channel: build-updates
    status: Dendra API Build Failed
    color: danger

- name: Notify Slack Success
  if: success()
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
  uses: voxmedia/github-action-slack-notify-build@v1
  with:
    channel: build-updates
    status: SUCCESS
    color: good

`

patrickmead commented 3 years ago

This is the portion of the build output for the deploy. I can post the rest of the output if this isn't sufficient.

I'm new to GitHub Actions but I have experience with Jenkins and Travis. Perhaps I'm missing something obvious.

Thanks again.

`##[debug]Evaluating condition for step: 'Deploy to Heroku'

[debug]Evaluating: success()

[debug]Evaluating success:

[debug]=> true

[debug]Result: true

[debug]Starting: Deploy to Heroku

[debug]Loading inputs

[debug]Evaluating: secrets.HEROKU_API_KEY

[debug]Evaluating Index:

[debug]..Evaluating secrets:

[debug]..=> Object

[debug]..Evaluating String:

[debug]..=> 'HEROKU_API_KEY'

[debug]=> '***'

[debug]Result: '***'

[debug]Loading env

Run akhileshns/heroku-deploy@v3.10.9 with: heroku_api_key: ** heroku_app_name: dendra-api-stage heroku_email: patrick@generalgalactic.io justlogin: true remote_branch: main branch: HEAD dontuseforce: false dontautocreate: false usedocker: false docker_heroku_process_type: web delay: 0 rollbackonhealthcheckfailed: false /usr/bin/docker exec d224d0edefcad3d011012710e18d99607e0374004dc00290bba841bf1aa1937a sh -c "cat /etc/release | grep ^ID"

[debug]ID=debian

[debug]Running JavaScript Action with default external tool: node12

Created and wrote to ~/.netrc /bin/sh: 1: heroku: not found Error: Error: Command failed: heroku login /bin/sh: 1: heroku: not found

[debug]Node Action run completed with exit code 1

[debug]Finishing: Deploy to Heroku`

AkhileshNS commented 3 years ago

I think it might have something to do with you using container: node:10.18-jessie. It's possible that it's because the node: 10.18-jessie image doesn't have heroku installed by default unlike the default ones used in github actions. Can you try adding the following step before the heroku deploy step and see if this works:

- name: Install Heroku Cli
  run: curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
patrickmead commented 3 years ago

@AkhileshNS That was it!

My last build ran with login only so I'm actually trying to deploy now.

I truly appreciate your quick reply and the assistance. Thanks again.