Deploying CircleCI changes to Heroku using Git

I am pretty new to Git and automated deployments, and I am trying to deploy the changes done as part of my CI to Heroku.

High-level idea:

  1. Send my code to github
  2. Circle picks it up, and does some minification
  3. Circle runs some tests
  4. Circle deploys to Heroku my files (including the changes I have done to them)

Everything works well, except the files I get on heroku seem to be the files on git, not the modified/minified files.

I guess the problem is coming from here in my yml:

    - image: buildpack-deps:trusty
    - checkout
    - run:
        name: Deploy Master to Heroku
        command: |
            git push https://heroku:$$HEROKU_APP_NAME.git master

However, I am not really sure how to change it.

A) Is it bad practice to send to Heroku directly the modified files? Should I first commit them to github in special release folder and then send that to heroku? how?
B) Is it just something missing in my yml?

Thank you for helping out a beginner :slight_smile:

You could do a git commit on CircleCI in the build repo, and then push that to Heroku. Don’t push to GitHub though - these are generated build artefacts and you don’t want them in your central repo, because they just replicate the source files.

I did this:

command: git config --global "" && git config --global "CircleCI test" && git add -f dist && git commit -m "Added dist files"

That seemed to work, but after the first commit, but now I am getting this:

git push https://heroku:$$HEROKU_APP_NAME.git master
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to ''
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Exited with code 1

I also tried to put a -f to my git push, and now I get:

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Exited with code 1

But the dist folder is still missing on Heroku

Ah yes, I guess that’s because CircleCI doesn’t just do a git clone in the checkout, it does all sorts of hard reset malarkey (open up the step in the build viewer to see what it does). I guess that because Heroku has an ordinary clone of your project, the new state of the repo at CircleCI is unmergeable.

You could try --force with your push - the remote copy on Heroku is just a throw-away copy anyway.

Thanks for your help, seems much more complicated than expected. I will create the files on Heroku directly with a postinstall script. Thanks for your help though

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.