DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Dale Zak
Dale Zak

Posted on • Originally published at dalezak.Medium

GitHub Action to Attach Commits and Pull Requests to Trello Cards

This GitHub Action lets you easily attach GitHub commits and pull requests to a Trello card simply by including the card number in your git commit message.


GitHub Issues is such a great tool for software development teams. However if the rest of your company is already using Trello, then you are faced with the decision whether to stick with Trello or switch to GitHub Issues.

The upside of sticking with Trello is that it’s already familiar for non-developers so it’s easy for other team members to submit bugs or feature requests. The downside of GitHub is the development team often works in a silo plus it adds another tool others need to become familiar with.

So for our team I decided to stick with Trello, however quickly noticed the disconnect between commits and Trello cards.

There are some GitHub Action out there that can mirror GitHub Issues to Trello Cards, however none really did want I wanted. So I ended up writing my own GitHub Action called GitHub-Commit-To-Trello-Card.

https://github.com/marketplace/actions/github-commit-to-trello-card


Here’s a sample of what the GitHub Action looks like.

name: GitHub Commit To Trello Comment

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - uses: dalezak/github-commit-to-trello-card@main
        with:
          trello-api-key: ${{ secrets.TRELLO_KEY }}
          trello-auth-token: ${{ secrets.TRELLO_TOKEN }}
          trello-board-id: ${{ secrets.TRELLO_BOARD }}
          trello-card-action: "Attachment"
          trello-list-name-commit: "Doing"
          trello-list-name-pr-open: "Reviewing"
          trello-list-name-pr-closed: "Testing"
Enter fullscreen mode Exit fullscreen mode

And these are what each of the action variables are.

  • trello-api-key β€” Trello API key, visit https://trello.com/app-key for key
  • trello-auth-token β€” Trello auth token, visit https://trello.com/app-key then click generate a token
  • trello-board-id β€” Trello board ID, visit a board then append .json to url to find id
  • trello-card-action β€” Trello card action, either β€œComment” or β€œAttachment”
  • trello-list-name-commit β€” Trello list name for new commit, for example β€œDoing”, β€œIn Progress”, etc
  • trello-list-name-pr-open β€” Trello list name for open pull request, for example β€œReviewing”, β€œIn Review”, etc
  • trello-list-name-pr-closed β€” Trello list name for closed pull request, for example β€œTesting”, β€œDone”, etc

Now to use the action simply include the card number in the git commit message.

git add .
git commit -m "Added initial login form for #751"
git push
Enter fullscreen mode Exit fullscreen mode

And voila! The commit message is magically attached to Trello card #751.

trello-card

I also setup the action to automatically move cards between lists. For example, when a pull request is opened it can move a card to β€œReviewing”, β€œIn Review”, etc, and when the pull request is closed it can move the card to β€œTesting”, β€œDone”, etc according to the trello-list-name-pr-open and trello-list-name-pr-closed variables. Enjoy!

Top comments (0)

Make Your Github Profile Stand Out

>> Check out this classic DEV post <<