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)