Hi everyone,
I have been using a Pipeline to deploy my Angular (2+ with CLI) application to Heroku for some time and it has generally been working very. One of the things that is a little cumbersome, however, is that I have to run my 'npm run build' (which then runs the command: "ng build --prod --output-path=../dist/", check that in, merge it to my master branch and then have the pipeline run. Ideally, I could just use 'ng serve' in development, check in the changes, merge them to the master branch and have the Pipeline run the build command and then push the correct files.
I figured out how to have the pipeline run the build command, but then it does not push the proper files to Heroku, it pushes outdated files, not the ones it created. I am sure there is just something I fundamentally don't understand or missed.
I just recently added the "cd ../" in my most recent attempt, but it didn't do anything.
Do I have to do anything to pull the committed master branch but then the newly generated files, or to commit the newly generated files to the master branch?
All help is appreciated - below is my pipeline file:
image: node:8.9.4
clone:
depth: full
pipelines:
branches:
master:
- step:
script:
- npm install
- cd angular-src && npm install @angular-devkit/build-angular
- npm install @angular-devkit/build-optimizer
- npm install -g @angular/cli
- ng build --prod --output-path=../dist/
- cd ../
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
Hi @blubberbo
If I understand your question correctly you are making changes to the checked out branch in your pipelines build and would like to deploy those changes to Heroku. This question specifically relates Heroku deployments so you might find related topics in their documentation and forums useful however let's see if we can help :)
To deploy your app to Heroku, you typically use the
git push
command to push the code from your local repository’smaster
branch to yourheroku
remote
Since Heroku deploys from your local branch, any changes you make must be committed to the local branch in order for them to be deployed. For example:
git add .
git commit
git push -f https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
Be careful when doing this however as this will move the remote Heroku branch ahead of your repository branch so subsequent deploys could fail with the following error.
hint: Updates were rejected because the remote contains work that you do
not have locally. This is usually caused by another repository pushing
to the same ref. You may want to first integrate the remote changes
(e.g., 'git pull ...') before pushing again.
To resolve this you can either:
I hope this helps.
Sam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.