Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.

Git push to heroku #10

Open
rickyhopkins opened this issue Dec 19, 2019 · 10 comments
Open

Git push to heroku #10

rickyhopkins opened this issue Dec 19, 2019 · 10 comments

Comments

@rickyhopkins
Copy link

I am trying to deploy to heroku with github actions using actions/heroku@master. I am not using docker so the standard directions for the heroku action does not really apply to me.

My current flow is:

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: login
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: container:login
    - name: set remote
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: git:remote -a my-app
    - name: push
      run: git subtree push --prefix server heroku master

It seems to login just fine and it adds the remote but then it fails when I try to push to heroku with the following message:

fatal: could not read Username for 'https://git.heroku.com': No such device or address

Which seems strange because the heroku login command should be adding my credentials to the .netrc file.

@deniscostadsc
Copy link

Hi,

@rickyhopkins, I'm having same problem here. Did you work around this in a clever way?

@rickyhopkins
Copy link
Author

Hey @deniscostadsc,

Nope, my project does not change too often so I have resorted to a manual deploy until I can get this working.

The only workaround that I found was here which suggests adding the Heroku remote manually with the API key injected in like so:

    - name: Add remote origin
      run: |
        git remote add heroku https://heroku:${{ secrets.HEROKU_API_KEY }}@git.heroku.com/${{ secrets.HEROKU_APP_NAME }}.git
    - name: Deploy to Heroku
      run: |
        git push heroku HEAD:master -f

I did not test this myself but I can't see why it wouldn't work it just feels like a bit of a hack to me.

Hope that helps.

@karimsa
Copy link

karimsa commented Jan 5, 2020

You don’t need the remote step so for my project, this is the solution I’m using:

  - name: Deploy to production
     run: |
       git push https://heroku:$HEROKU_API_KEY@git.heroku.com/<heroku-project>.git master

@deniscostadsc
Copy link

@karimsa,

I tried an approach similar to yours, but I keep getting errors. I even tried to put hardcode URL with secret API key (don't worry I already invalidated it 😎) and got same error bellow:

Run git push ***git.heroku.com/<heroku-project>.git master
  git push ***git.heroku.com/<heroku-project>.git master
  shell: /bin/bash -e {0}
error: src refspec master does not match any
error: failed to push some refs to '***git.heroku.com/<heroku-project>.git'

@karimsa
Copy link

karimsa commented Jan 6, 2020

Is the branch that ran the workflow master? If not, you can try changing master to HEAD:master in the above command.

@deniscostadsc
Copy link

After changing my code to this:

STAGING_GIT_URL=$(git remote get-url staging | sed 's/\/git/\/heroku:${{ secrets.HEROKU_API_KEY }}@git/')
git remote set-url staging $STAGING_GIT_URL
git push staging HEAD:master

I start to get this error:

Run STAGING_GIT_URL=$(git remote get-url staging | sed 's/\/git/\/heroku:***@git/')
  STAGING_GIT_URL=$(git remote get-url staging | sed 's/\/git/\/heroku:***@git/')
  git remote set-url staging $STAGING_GIT_URL
  git push staging HEAD:master
  shell: /bin/bash -e {0}
error: The destination you provided is not a full refname (i.e.,
starting with "refs/"). We tried to guess what you meant by:

- Looking for a ref that matches 'master' on the remote side.
- Checking if the <src> being pushed ('HEAD')
  is a ref in "refs/{heads,tags}/". If so we add a corresponding
  refs/{heads,tags}/ prefix on the remote side.

Neither worked, so we gave up. You must fully qualify the ref.
hint: The <src> part of the refspec is a commit object.
hint: Did you mean to create a new branch by pushing to
hint: 'HEAD:refs/heads/master'?
error: failed to push some refs to '***git.heroku.com/<heroku-project>.git'

I think my error is more related to git that Heroku actually.

Thanx for the help so far.

@deniscostadsc
Copy link

Just for the sake of history, my problem seems to be caused by the state of detached of the repo on build. I'm confused why you didn't have this problem.

@deniscostadsc
Copy link

Yes, it was the detached state. I used a semi-hacky solution of creating a branch before pushing to github.

@spk
Copy link

spk commented Jan 7, 2020

o/ for other people looking for an example with Heroku git push deploy on pull request with a comment /deploy https://gist.github.com/spk/7be27d8f0f9fa0264fa24417ec40c742 secrets needs to be provided and also the HEROKU_APP_NAME changed

@rohitkrishna094
Copy link

@deniscostadsc do you have a sample yaml file for that hacky solution that you mentioned?

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

No branches or pull requests

5 participants