The authentication server for CocoaPods push
Ruby HTML CSS
Clone or download
Permalink
Failed to load latest commit information.
.travis [travis] Working on CI Nov 28, 2015
app Merge pull request #229 from CocoaPods/131_warn Aug 6, 2017
config Update init.rb Feb 28, 2018
db [RuboCop] Fix violations Jan 26, 2016
design [Rubocop] Fix StringLiterals Apr 9, 2014
doc Add docs on Emails Oct 24, 2016
lib [RuboCop] Fix violations Jan 26, 2016
public use retina preview image, and use new command in image May 21, 2014
script Update sharding to the final script Nov 11, 2016
shared @ 38a7d83 [Shared] Update to CocoaPods/shared_resources@38a7d83 Oct 27, 2015
spec Merge pull request #229 from CocoaPods/131_warn Aug 6, 2017
.env.sample Ensure rack attack is green, add env sample to the repo Feb 9, 2016
.gitignore Do not ignore tmp/README. May 15, 2014
.gitmodules Properly add shared submodule. Feb 9, 2014
.kick [Kicker] Added .kick file May 23, 2014
.rubocop.yml Update RuboCop and use CocoaPods config Jan 26, 2016
.rubocop_cocoapods.yml Update RuboCop and use CocoaPods config Jan 26, 2016
.rubocop_todo.yml [RuboCop] Fix violations Jan 26, 2016
.ruby-version [Ruby Version] Change to the correct version 2.1.3 Dec 28, 2014
.travis.yml Update CocoaPods Core Sep 9, 2017
Gemfile Adds a slack notification when a dispute is resolved Jan 13, 2017
Gemfile.lock Update cocoapods-core to 1.5.0 Apr 4, 2018
LICENSE Add README and LICENSE Aug 3, 2013
Procfile [Webhook] Remove from Podfile. May 18, 2014
README.md [README] Add note on public non-availability of webhooks. May 26, 2014
Rakefile Adds a check for the length of a dispute Dec 23, 2016
config.ru Make memcache only load on prod/testing Dec 23, 2016
webhook_test.rb [RuboCop] Run on scripts Apr 1, 2016

README.md

trunk.cocoapods.org

Build Status

Available under the MIT license.

Installation

  1. Create a testing sandbox repository on GitHub and, from the CocoaPods specification repository, add the Gemfile and Rakefile files.

  2. Install PostgreSQL. (On OS X you can use the Postgres App.)

  3. Install the dependencies:

     $ rake bootstrap
    
  4. Create and migrate the databases for the various environments:

     $ rake db:bootstrap RACK_ENV=test
     $ rake db:bootstrap RACK_ENV=development
    
  5. Test whether or not a pod sends correctly

     $ ./bin/test-push localhost:4567 spec/fixtures/AFNetworking.podspec
    

Usage

To start a development server run the following command, replacing the environment variables with your GitHub credentials, a GitHub testing sandbox repository, and a SHA hashed version of the password for the admin area (in this example the password is ‘secret’):

env RACK_ENV=development \
    GH_USERNAME=alloy GH_EMAIL=user@example.com GH_TOKEN=secret GH_REPO=alloy/trunk.cocoapods.org-test \
    TRUNK_APP_PUSH_ALLOWED=true TRUNK_APP_ADMIN_PASSWORD=2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b \
    rake serve

Optional environment variables are:

  • RACK_ENV: Can be test, development, or production.
  • DATABASE_URL: The URL to the PostgreSQL database.

Webhook

The webhook sends messages to other services when events in trunk happen.

These events trigger the webhook and send a message.

  • Successful create of a pod: {'type':'pod','action':'create','timestamp':'<date>','data_url':'<URL>'}
  • Successful create of a version: {'type':'version','action':'create','timestamp':'<date>','data_url':'<URL>'}
  • Successful update of a spec: {'type':'spec','action':'update','timestamp':'<date>','data_url':'<URL>'}

Environment variables are:

  • OUTGOING_HOOK_PATH: The garbled path used at the end of <schema>://<domain>/hooks/trunk/<OUTGOING_HOOK_PATH>.
  • WEBHOOKS_ENABLED: If set to true, the webhook is enabled.

Usage in Trunk

Enable:

Webhook.enable

Disable:

Webhook.disable

Trigger a message explicitly:

Webhook.pod_created(created_at, data_url)
Webhook.version_created(created_at, data_url)
Webhook.spec_updated(updated_at, data_url)

Change the webhook service URLs with the hook config methods:

Webhook.pod_created = [urls]
Webhook.version_created = [urls]
Webhook.spec_updated = [urls]

Check if it is enabled:

Webhook.enabled?

Usage in interested web services

Note: The webhooks are currently only available to CP internal services. We are looking into opening them up for public use after some intensive testing.

  1. Add your URL wherever one of the hook config methods (see above) is called (currently in ìnit.rb).
  2. We recommend you add OUTGOING_HOOK_PATH to the path to at least obscure your path.
  3. Install a POST route in your service that corresponds to the URL. Note: You MUST NOT use the value in OUTGOING_HOOK_PATH inside your public code. Instead, use an ENV variable as well, and set it to correspond to OUTGOING_HOOK_PATH.

You'll then receive POSTs to the URL with content message=<JSON data>.