How to auto-upgrade a gem in travis? - ruby-on-rails

I help to maintain an open source project, Hyrax, which is a rails engine. In order to do QA on new development, we maintain an application that is specifically for QA, Nurax, which should always be updated with the latest master of the rails engine. I have specified the master branch of Hyrax in the Gemfile for Nurax, and if I run bundle update hyrax it will indeed get the latest master version and update the Gemfile.lock accordingly. I can also get Nurax to deploy automatically via Travis. However, that auto-deploy does not automatically update to the latest master of Hyrax before deploying, which is what I really want to happen.
What is the best way to set this up? Should I have travis run a bundle update hyrax and commit that change to Nurax master as part of its build? I've found a few topics about committing from a travis build (e.g., this one). Would it be better to make a new Nurax branch for each PR and deploy that branch? Is there an established pattern for this that I could be following?
Any advice greatly appreciated.

I ended up solving this with a cron job. I checked out a local copy of the code on the server in question, in the home directory of my ubuntu user. I then added the ubuntu user's ssh key to my own github account, and to the account used for capistrano deploy. Then, I set this up to run daily:
#!/usr/local/bin/ruby
# Get the latest nurax master
# Make a branch with today's date and update hyrax
# Push and deploy that branch
today = Time.now.strftime('%Y-%m-%e-%H-%M')
`cd /home/ubuntu/nurax; git checkout master; git pull; git checkout -b "#{today}"`
`cd /home/ubuntu/nurax; bundle update hyrax`
`cd /home/ubuntu/nurax; git commit -a -m 'Daily update for "#{today}"'; git push --set-upstream origin #{today}`
`cd /home/ubuntu/nurax; BRANCH_NAME="#{today}" cap nurax-dev deploy`
`cd /home/ubuntu/nurax; git checkout master; git branch -d "#{today}"; git push origin --delete "#{today}"`

Related

Pull changes from github to local rails files

So I know how to update the repository with my files (the master one at least). And I know I can create a local branch with
$ git checkout -b [branch_name]
but that only creates it on the local git...how do i checkout a branch from the master on github and also overwrite files in my app directory, so I can update my project with the work of other people
Do you mean to ask, how to reset master on your local machine to that of the master on the origin?
If so:
Fetch all remote/origin changes and then hard reset your local master to origin/master's head:
$ git checkout master
$ git fetch --all
$ git reset --hard origin/master

how do I continue my app after deploy

So I have deployed my rails app on a VPS with Ubuntu Server and Apache,
following this tutorial . Everything is working perfectly except that I'm not sure on how to continue to develop my app, bitbucket is configured and working but I don't want to commit and push every time since I make a lot of try and errors. So I'm looking for an easy way to continue to develop and test.
I will appreciate any answers and recommendations , thank you.
You can keep building your into local machine.
Create a branch git checkout -b branch_name
You can make changes and test this branch.
git add -A
git commit -m "Suitable message"
git checkout master
git pull origin master
git merge branch_name
git push origin master
P.S : You can continue your development in master branch too.

Rubyonrails cloud9 to bitbucket to heroku update

How do I edit my web page using cloud9 bitbucket after it is launched on heroku?
I have already saved changes on cloud9 and posted a git commit and am in bitbucket.
Do i create a new repository? or how to add to the existing one?
Could someone explain each step?
Assuming you have a bitbucket repository set up and reflecting your production code, you should generally be doing the following:
git checkout -b new-feature # create repository branch `new-feature` to do more work
... make a bunch of changes and test them ...
git add -A # add all of your changed files
git commit -am "Meaningful comment" # comment which goes with your commit describing what you did
git checkout master # get back to master
git merge new-feature # ... and merge your changes into it
git push # push all of your changes to bitbucket
git push heroku # deploy to production with Heroku
Hopefully, many of these commands are familiar already... otherwise, take a look at the docs to make sure you understand first.
Hope this helps.

Bamboo infinite loop

Having some major issues with Bamboo.
I run a rails project, that runs on Engine Yard.
My build strategy is as follows
Checkout from Source Code
bundle install
rspec (run tests)
Tag my build
(code to create tag causes new commit, tag used in deploy)
git remote remove origin
git remote add origin <my repo>
git tag Bamboo-${bamboo.buildNumber}
git push origin Bamboo-${bamboo.buildNumber}
In my deploy the way engine yard works is you deploy based on branches or tags ( there is no build artifacts)
So in my Deploy it's a single script that uses a gem https://github.com/engineyard/engineyard
and runs
ey deploy --environment <staging> --tag=Bamboo- ${bamboo.buildNumber} --app <my app>
Engine yard does all the rails 'stuff' to prep the build and deploy it. Really just need Bamboo to run test and if it works tag build.
PROBLEM
I am using bitbucket source control and have configured a hook to trigger a bamboo build on any commit to master.
The issue step 4) is pushing a tag which causes bitbucket to execute another build
Resulting in infinitely building bamboo.
Looking into how to solve this. Figured I could use Bamboo 'Exclude Changesets' and filter out a particular commit message
https://confluence.atlassian.com/display/BAMBOO/Bitbucket?focusedCommentId=610435557&#comment-610435557
so my 4) would now look like
git remote remove origin
git remote add origin <my repo>
#create tag
git tag -a Bamboo-${bamboo.buildNumber} - m 'bamboo build'
#push tag
git push origin Bamboo-${bamboo.buildNumber}
However as per the comments on that confluence page. Exclude Changsets isn't a visible option anymore?
I don't understand how I can stop this infinite building loop.
We use Bamboo and a tag doesn't kick off the build for us.
Our tag process is:
git tag -a v1.4.2 -m 'Production Release: [date]
git push origin --tags
Try using the --tags option when pushing.

GIT how to delete branch if remote missing

I have a Rails app that I deployed to Heroku for testing.
I deleted the Heroku version of the app from the Heroku site.
Now, I'm trying to delete the Heroku git branch from my local development and it won't let me because it can't logon to the deleted Heroku app/git.
How can I delete the Heroku git branch?
Thanks!
Remote tracking branches, the branches that appear in git branch -r with names like heroku/master, are deleted when you delete the remote they belong to:
git remote rm heroku
(Where "heroku" is the name of the remote you were using to push to heroku.)
If you have local branches that you want to get rid of, as well, you can delete those normally with git branch -d (which only succeeds if the branch is already merged in) and git branch -D (which works if it isn't).

Resources