No commit activity in last 3 years
No release in over 3 years
By requesting trigger build to Wercker with an environment variable which instruct wercker.yml to execute this script, bundle update is invoked, then commit changes and send pull request to GitHub repository if there some changes exist.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 5.0
~> 10.0

Runtime

 Project Readme

wercker-bundle-update-pr

This is an automation script to bundle update and send pull request via Wercker's Trigger Build API. By requesting trigger build to Wercker with an environment variable which instruct wercker.yml to execute this script, bundle update is invoked, then commit changes and send pull request to GitHub repository if there some changes exist.

(Both concept and implementaion are strongly based on circleci-bundle-update-pr.

Installation

$ gem install wercker-bundle-update-pr

Usage

Prerequisites

The application on which you want to execute bundle update automatically must be on a Wercker CI.

Getting GitHub Personal access token

A GitHub personal access token is required for sending GitHub pull request. Go to your account's settings page and obtain a personal access token.

Getting Werkcer personal token

A Wercker personal token is required for invoking Trigger Build API. Go to your account's settings page and obtain a personal token.

Wercker application configuration

In the application's setting page:

  1. Generate SSH key named "wercker_github_ci_key" in "SSH Keys" for pushing changes to GitHub
  2. Register the above generated key to GitHub SSH keys in Personal settings
  3. In "Environment variables", add GITHUB_ACCESS_TOKEN with a GitHub personal access token (Make sure you mark it "protected" otherwise it will be shown in logs)
  4. In "Environment variables", add WERCKER_GITHUB_CI_KEY as SSH key pair and select "wercker_github_ci_key"

Configure wercker.yml

Add the following 2 steps under steps to access GitHub via SSH (Set GitHub's SSH key RSA fingerprint to <fingerprint>. See What are GitHub's SSH key fingerprints?):

    - add-ssh-key:
        keyname: WERCKER_GITHUB_CI_KEY

    - add-to-known_hosts:
        hostname: github.com
        fingerprint: <fingerprint>

then add this step as well (replace <username> and <email> with yours).

    - script:
        code: |
          if [ "${BUNDLE_UPDATE}" ] ; then
            gem update bundler -N
            gem install wercker-bundle-update-pr -N
            wercker-bundle-update-pr <username> <email>
          fi

Do not forget git commit and git push these changes.

Fire Trigger build API

Now all set to fire Trigger build API.

$ curl -H 'Content-Type: application/json' -H "Authorization: Bearer <wercker personal token>" -X POST -d '{"applicationId": "<wercker application id>", "branch":"master", "message":"bundle update via trigger build", "envVars":[{"key":"BUNDLE_UPDATE","value":"true"}]}' https://app.wercker.com/api/v3/builds

You have to replace <wercker personal token> with your Wercker personal access token, and replace <wercker application id> which you can find in the URL of your wercker application.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/5t111111/wercker-bundle-update-pr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.