Sha256: 4a3bae64b62f43b9848fa7ba10fe3240297b091cfff9a04f00e4896731d7ff94
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
# OrgUpdateMatrix This gem revceives data from a Capistrano run and updates a specified YAML file in the specified GitHub repository. Depends on the "octokit" gem [https://github.com/octokit/octokit.rb](https://github.com/octokit/octokit.rb) ## Installation Add this line to your application's Gemfile: ```ruby gem 'orgupdatematrix' ``` And then execute: $ bundle Or install it yourself as: $ gem install orgupdatematrix ## Usage Add to your Capfile: `require 'orgupdatematrix'` Add an `:app_url` variable to each deploy env file such as `deploy/environments/staging.rb`: ``` set :app_url, 'https://staging.my-application.com' ``` Auth: generate a GitHub [personal access token](https://github.com/settings/tokens) and supply it at deploy time: ``` GITHUB_API_TOKEN=token-value cap production deploy ``` Add the following task to your Capistrano config eg. `deploy/config.rb`: ``` desc 'Update Matrix' task :update_matrix do optional_extras = { 'my_var1' => 'value1', 'my_var2' => 'value2' } on roles(:web) do within repo_path do info 'Updating deploy matrix!' commit = capture(:git, 'rev-list', '-n', '1', fetch(:branch)).chomp updater = OrgUpdateMatrix::Updater.new('GitHubUser/RepoName', 'file-path.yml', ENV['GITHUB_API_TOKEN']) updater.update(fetch(:application), fetch(:stage), fetch(:branch), commit, fetch(:app_url), fetch(:repo_url)) end end end after :finished, :update_matrix ``` This will update the remote YAML file to look like this: ``` --- app_name: stage_name: branch: branch_or_tag_name commit: 6209dc2138df2ecb808559d8f1c5bc41bfd17d0d updated: 2019-05-09 03:51:50 UTC app_url: https://staging.my-application.com github_url: https///github.com/MyUser/AppRepo.git extras: my_var1: value1 my_var2: value2 ``` Only the specified `application` + `stage` section will be updated. The rest of the file's contents will remain unchanged.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
orgupdatematrix-0.1.2 | README.md |