My deploy script is an extremely simple Git pull. I have a bash script that does git pull that’s part of my source code. The issue is that if the git pull fails for any reason, it’s still showing a successful deploy.
In circle CI, my deploy commands are:
deployment:
prod:
branch: master
commands:
- ./deploy-to-production.sh
staging:
branch: staging
commands:
- ./deploy-to-staging.sh
deploy-to-production is a simple script that lets CircleCI ssh and run the pull
#!/usr/bin/env bash
ssh myuser@xxx.myserver.com -i ~/.ssh/mykey.pub -t “cd /home/xxxxx/yyyyy && ./deploy.sh”
The issue is that git pull can fail, but the deploy still shows that it passes. Below is the output (the git conflict caused it to fail) but CircleCI shows green.
./deploy-to-production.sh
Warning: Identity file /home/ubuntu/.ssh/mykey.pub not accessible: No such file or directory.
Warning: Permanently added ‘xxxx.myserver.com,123.123.123.123’ (ECDSA) to the list of known hosts.
Deploying…
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:myaccount/myproject
f23cff8…1793a48 master -> origin/master
Updating f23cff8…1793a48
error: Your local changes to the following files would be overwritten by merge:
mysqlbackup.sh
Please, commit your changes or stash them before you can merge.
Aborting
Running any db migrations.
Yii Migration Tool v1.0 (based on Yii v1.1.8)
No new migration found. Your system is up-to-date.
Deployed.
Connection to xxxxx.server.com closed.