Node to Heroku

I’m extremely new to ci/cd, this is the first ever pipeline that I’ve written and so I wanted to keep it simple but it failed. I just want my node app to go through the following pipeline: npm ci --> build --> push to heroku. This works except for the last step where this error happens:

error: src refspec master does not match any

error: failed to push some refs to ‘heroku’ 

##[error]Process completed with exit code 1. 

Frankly, I wouldn’t know how to fix this because if I type all commands manually in my terminal, they work just fine.

my nodejs.yml file:

name: Node CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [8.x, 10.x, 12.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: npm install, build, and push to heroku
      run: |
        npm ci
        npm run build --if-present
        git push heroku master
      env:
        CI: true
1 Like

The checkout action runs “git fetch” and “git checkout sha” command to checkout resources to the workflow runner which makes the repository in a “detached HEAD” state as below:

This is why you get error: “error: src refspec master does not match any”.

Checkout/Switch to a branch should be able to fix this.

Hi @moutpessemier,

Here’s an example for deploying to Heroku: https://mikecoutermarsh.com/github-actions-deploy-to-heroku/

I have it working for a Rails app. Thinking it should be pretty much the same for a Node app. Hope that helps!