Integrate Trello on Pantheon with Quicksilver Hooks
Learn how to integrate Trello with your dev workflow on Pantheon.
Contributors: Scott Massey.
Discuss in our Forum Discuss in SlackTrello is a simple yet powerful project management tool which helps teams to collaborate on projects in an agile framework. Trello lends itself to not only web projects, but also helps businesses keep other internal tasks and objectives organized.
In this guide, we'll use a Trello instance with a site on Pantheon. When changes are pushed to Pantheon that reference a Trello card's unique ID, the commit message will appear in the card.
Before You Begin
Be sure that you:
Have a Drupal or WordPress site on Pantheon
Install Terminus:
curl -O https://raw.githubusercontent.com/pantheon-systems/terminus-installer/master/builds/installer.phar && php installer.phar installGenerate a Machine Token from User Dashboard > Account > Machine Tokens, then authenticate Terminus:
terminus auth:login --machine-token=‹machine-token›Install the Terminus Secrets Plugin:
curl https://github.com/pantheon-systems/terminus-secrets-plugin/archive/1.x.tar.gz -L | tar -C ~/.terminus/plugins -xvz
Create a Machine User in Trello
Start by creating a new machine user in your Trello instance. This user is referred to as a "machine user" because the account is used to automatically create comments out of commit messages on Pantheon using a PHP script.
If you haven't done so already, create a team. Login to your Trello instance and click , found in the upper panel, then select Create Personal Team or Create Business Team, depending on your plan. Add a team name and click Create:
If you already have a team, select it from your dashboard.
Under Add Members, select Add by name or email.
Enter a name and email address for the machine user, which acts as the intermediary between Trello and the Pantheon Site Dashboard.
We suggest naming machine users relative to their function, in this example we name our new user
Automation User. The email needs to be an account you have access to:
Login as the new "Automation User" and make sure you're a team member on the relevant board:
Copy the machine user's API key from here, then click the link to manually generate a Token:
Save your key and token, to be used in the next section.
Securely Store User Credentials on Pantheon
Next, we need to provide Pantheon with the credentials for our new machine user. We'll securely store these values in the private path of Pantheon's filesystem.
We use the filesystem private path in this section because we don't want to track sensitive data like passwords in the codebase with git.
First, let's check for existing secrets using Terminus (replace
<site>with your site name):SITE=<site> terminus secrets:list $SITE.devIf no existing keys are found, execute the following to create a new
secrets.jsonfile and upload it to Pantheon:$ echo '{}' > secrets.json $ `terminus connection:info $SITE.dev --field=sftp_command` sftp> put ./files/private secrets.json sftp> bye $ rm secrets.jsonOtherwise, continue to the next step.
Use Terminus to store the Automation User's API key in the the private
secrets.jsonfile (replace<API key>):terminus secrets:set $SITE.dev trello_key '<API key>'Use Terminus to store the Automation User's token in the the private
secrets.jsonfile (replace<Token>):terminus secrets:set $SITE.dev trello_token '<Token>'
Note
When it comes to keeping production keys secure, the best solution is to use a key management service like Lockr to automatically encrypt and secure keys on distributed platforms such as Pantheon.
Configure Quicksilver Integration
Next we'll add Pantheon's example Quicksilver integration script for Trello to the private path of your site's codebase. The private path within the codebase is tracked in version control and is accessible by PHP, but not the web.
If you haven't done so already, clone your Pantheon site repository and navigate to the project's root directory:
`terminus connection:info $SITE.dev --fields='Git Command' --format=string` cd $SITESet the connection mode to Git:
terminus connection:set $SITE.dev gitCreate a copy of Pantheon's
trello_integration.phpin the project's private path:mkdir private mkdir private/scripts curl https://raw.githubusercontent.com/pantheon-systems/quicksilver-examples/master/trello_integration/trello_integration.php --output ./private/scripts/trello_integration.phpCreate a
pantheon.ymlfile if one doesn't already exist in your root directory.Paste the following workflow into your
pantheon.ymlfile to hook into the platform upon code being pushed to fire off the Trello integration script:#always include the api version api_version: 1 workflows: sync_code: after: - type: webphp description: Trello Integration script: private/scripts/trello_integration.phpNote
api_versionshould be set once inpantheon.yml. If you have an existingpantheon.ymlwith this line, don't add it again.Commit and push changes to the Dev environment:
git commit -am "Create private/scripts/trello_integration.php and configure platform hooks" git push origin master
Test Trello Integration on Pantheon
Create a test issue in an existing or new Trello project. Copy the issue ID, which is located in the Trello card's URL:
Note
In a separate teriminal window, run
terminus workflow:watch $SITEto see the process unfold in real time (optional).Push a code change to Pantheon containing the Trello card ID in the commit message in brackets (e.g., [4K2zqr1A]). This workflow will trigger
trello_integration.phpscript, which will search commits for possible issue IDs and comment in Trello when found.git commit -m "[4K2zqr1A]: Require wp-redis as dropin via Composer"Return to the issue in Trello to see a message from our machine user:
Conclusion
In this guide, we covered a simple integration between Trello and Pantheon. There are other ways to connect your Trello with your development workflow on Pantheon if you also use an external repository such as GitHub. This integrations work in the opposite direction, allowing you to attach pull requests, issues, and commits directly to your Trello cards, from the Trello dashboard. Using and extending integrations like these will provide clarity into work being performed by you and your team, while speeding up the development process.