Error while pushing from bitbucket repo to heroku. It says my repo is a shallow clone - node.js

I created a pipeline to deploy my code from Bitbucket repo to Heroku server.
my bitbucket-pipelines.yml
image: node:10.15.3
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- npm install
- git push https://heroku:<my heroku api key>#git.heroku.com/<my heroku app's name>.git HEAD
After pushing my code to my bitbucket repo, the pipeline runs, but fails while pushing the code to heroku git.
Below is the error:
Push rejected, source repository is a shallow clone. Unshallow it with `git fetch --all --unshallow` and try pushing again.
But then by bit bucket repo is not shallow. The command git rev-parse --is-shallow-repository returns false.

You can use the following git command before the push
git filter-branch -- --all
So it would be in your script:
...
- git filter-branch -- --all
- git push https://heroku:<my heroku api key>#git.heroku.com/<my heroku app's name>.git HEAD

Related

Gitlab CI is ignoring ci.skip

I'm trying to create a pipeline on Gitlab CI that increments the app version everytime we get a commit on master. But it is ignoring my ci.skip command and I don't know why.
The yaml file is this one:
.gitlab-ci.yml
workflow:
rules:
- if: $CI_COMMIT_BRANCH == 'master'
before_script:
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- git remote set-url origin https://push:$PUSH_KEY#$CI_SERVER_HOST/$CI_PROJECT_PATH.git
auto_release:
image: node:10
script:
- yarn
- yarn release
- git push --follow-tags origin HEAD:master -o ci.skip
- echo "Done!"
So everytime I push a new commit it gets locked inside an eternal loop that commits a new version and commits a new version over and over again. The only way to stop is manually cancelling the jobs.
Pleas note: When we use the image node or node:latest it works, but our version requires node:10 otherwise it will break and won't build.
node:10 is a very old image. The git version it contains does not support push options (at least with the shorthand -o), so that's why the push triggers the next CI build.
Check the git version in the image - if it's 2.10 to 2.17 you can use --push-option=ci.skip. If it's still an older version, you need to create your own docker image that contains node version 10 and a modern git version.

How to update Heroku along with Github after the first time commit and creating Heroku app?

I have created my Heroku app via github with first commit by following commands.
git init
git add .
git commit -m "my first commit"
heroku login
heroku create
git push heroku HEAD:master
My app got created successfully. But I don't know which commands to use after then - if again i want to deploy it after making some changes in my existing code? What are the exact commands then for github and heroku both respectively.
You can re-deploy your app with the same commands you have done before.
Commands
git add .
git commit -m "new commit"
git push heroku master
Use git push for GitHub

Unable to push into gitlab as part of CI pipeline

I am trying to modify the package.json for version string and committing as part of CI but git push is failing for me. Following is the code in gitlab-ci.yml in my stage:
before_script:
- git remote set-url origin https://userid:${CI_PUSH_TOKEN}#gitlaburl.com/datastorage/project.git
script:
- call npm install gulp-json-modify --save
- git checkout -B myBranch
- call npm run modifyBuildVersion
- git add package.json
- git commit -m "[skip_ci]Automated commit from CI runner"
- git push --follow-tags origin myBranch
Where CI_PUSH_TOKEN is an environment variable I created under settings->CI/CD and this key contains the value of personal access tokens.
In the step of git push I am getting an error
"remote: HTTP Basic: Access denied fatal: Authentication failed for"
Any idea what's going wrong here?
I tried to search around but didn't get much help.
Did you give at least developer right for userid on your repo ?
If you use use the gitlab-ci-token as user, you are not able to push for the moment (in Gitlab 11.8). There is an open feature request.

Heroku build failing, 'fatal: Not a git repository'

I'm trying to deploy my app to Heroku but keep getting the error
fatal: Not a git repository (or any parent up to mount point /tmp) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).'
Here under the commands I type
$ git branch
-> master
$ git add -A
$ git commit -m'commit'
...your branch is up to date
$ git push
everything-up-to-date
$ heroku create drumbo
Creating ⬢ drumbo... done
https://drumbo.herokuapp.com/ | https://git.heroku.com/drumbo.git
$ heroku buildpacks:set heroku/nodejs
Buildpack set. Next release on sampleapp will use heroku/nodejs.
Run git push heroku master to create a new release using this buildpack.
$ git init (added this in because of https://stackoverflow.com/questions/16853624/git-discovery-across-filesystem-not-set)
Reinitialized existing Git repository in /Users/Berta/Desktop/Codes-senior/sampleapp/.git/
$ git push heroku master
...(fails with) - fatal: Not a git repository (or any parent up to mount parent /home/kozi) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
$ git status
On branch master
your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
$ ls -A
... .git, .github ...
There's also a decent amount of verbiage about npm-merge-driver in the terminal log. Looks like the build fails right after npm install npm-merge-driver is called -
> drumbo#1.0.0 prepare /tmp/build_77f785ef804afd5c02fbe1c7b6f209fd
remote: > npm-merge-driver install
remote:
remote: fatal: Not a git repository (or any parent up to mount
point /tmp)
remote: Stopping at filesystem boundary
(GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
remote:
/tmp/build_77f785ef804afd5c02fbe1c7b6f209fd/node_modules/npm-merge-
driver/node_modules/yargs/yargs.js:1100
However when I uninstalled the npm-merge-driver, build failed because it wasn't found.
What's happening?
Two things - you need to delete the prepare line from your package.json file (should be the line referring to npm-merge-driver,
and you need to make sure you add, commit, and push your code before you run npm run deploy - should clear anything up

Heroku doesn't re-deploy my app when I git merge

I have been push useless commits just to ensure heroku reloads and redeploys my app after using git merge to make changes to master. Am I missing something?
EDIT
Im deploying straight from git. Hence no git push heroku master.
I found the solution.
Under the deploy tab in heroku i can choose to deploy manually from my git branch as seen below.
To make your changes appear in the remote repo, you have to push them. Your normal dev cycle should be:
Create a branch
git checkout -b NEW_BRANCH
Work & commit changes
git commit -am "commit message"
if you work in the same branch with your teammates, then you can push changes to the remote repo, but it will only push to that branch
git push REMOTE_REPO NEW_BRANCH
Merge your branch to master branch
git checkout master
git merge NEW_BRANCH
Push changes to the remote
git push <REMOTE_NAME> master
which in your caseREMOTE_NAME is heroku, so
git push heroku master
should send all your commits to deploy to heroku

Resources